博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java Byte类parseByte()方法的示例
阅读量:2549 次
发布时间:2019-05-11

本文共 3116 字,大约阅读时间需要 10 分钟。

Syntax:

句法:

public static byte parseByte(String str);    public static byte parseByte(String str, int radix's);

短类parseByte()方法 (Short class parseByte() method)

  • parseByte() method is available in java.lang package.

    parseByte()方法在java.lang包中可用。

  • parseByte(String str) method is used to return the byte value corresponding to the given String denotation or in other words we can say this method is used to convert string value to a byte value.

    parseByte(String str)方法用于返回与给定String表示形式相对应的字节值,换句话说,我们可以说此方法用于将字符串值转换为字节值。

  • parseByte (String str, int radix's) method is used to return the byte value corresponding to the given String denotation as a signed byte in the radix's given by the second argument.

    parseByte(String str,int radix's)方法用于返回与给定String表示形式对应的字节值,作为第二个参数给定的基数中的有符号字节。

  • parseByte(String str), parseByte(String str, int radix's) method may throw a NumberFormatException at the time of conversion from String to byte.

    从字符串到字节的转换时, parseByte(String str)parseByte(String str,int radix's)方法可能会引发NumberFormatException。

    NumberFormatException: In this exception, if String does not contain the parsable number.

    NumberFormatException:在此异常中,如果String不包含可分析的数字。

  • These are static the methods, they are accessible with the class name too and, if we try to access these methods with the class object then also we will not get an error.

    这些是静态方法,它们也可以通过类名进行访问,而且,如果我们尝试使用类对象访问这些方法,那么也不会出错。

Parameter(s):

参数:

  • In the first case, String value – represents the value of String type.

    在第一种情况下, 字符串值 –表示字符串类型的值。

  • In the second case, String value, int radix's – In this method first parameter value represent the value of String type in the radix's given by the second parameter.

    在第二种情况下, String值,int radix's –在此方法中,第一个参数值表示第二个参数给定的基数中String类型的值。

Return value:

返回值:

In the first case, the return type of this method is byte - it returns the byte representation of this String argument.

在第一种情况下,此方法的返回类型为byte-它返回此String参数的字节表示形式。

In the second case, the return type of this method is byte - it returns the byte representation of the String argument in the radix's given by the second argument.

在第二种情况下,此方法的返回类型为byte-它以第二个参数给定的基数形式返回String参数的字节表示形式。

Example:

例:

// Java program to demonstrate the example // of parseByte() method of Byte classpublic class ParseByteOfByteClass {
public static void main(String[] args) {
// Variables initialization String str1 = "100"; String str2 = "67"; int radix = 10; // Object initialization Byte b1 = new Byte(str2); // It convert string into byte by calling parseByte(str1) method // and store the result in another variable of byte type byte result = b1.parseByte(str1); // Display result System.out.println("b1.parseByte(str1): " + result); // It convert string into byte with radix 20 by calling parseByte(str1,radix's) method // and store the result in a variable of byte type result = b1.parseByte(str1, radix); // Display result System.out.println("b1.parseByte(str1,radix): " + result); }}

Output

输出量

b1.parseByte(str1): 100b1.parseByte(str1,radix): 100

翻译自:

转载地址:http://dpvzd.baihongyu.com/

你可能感兴趣的文章
linux awk命令详解
查看>>
OO第一次总结博客
查看>>
day7
查看>>
iphone移动端踩坑
查看>>
vs无法加载项目
查看>>
Beanutils基本用法
查看>>
玉伯的一道课后题题解(关于 IEEE 754 双精度浮点型精度损失)
查看>>
《BI那点儿事》数据流转换——百分比抽样、行抽样
查看>>
哈希(1) hash的基本知识回顾
查看>>
Leetcode 6——ZigZag Conversion
查看>>
dockerfile_nginx+PHP+mongo数据库_完美搭建
查看>>
Http协议的学习
查看>>
【转】轻松记住大端小端的含义(附对大端和小端的解释)
查看>>
【转】在Ubuntu 12.04 上为Virtualbox 启用USB 设备支持--不错
查看>>
设计模式那点事读书笔记(3)----建造者模式
查看>>
tar命令
查看>>
cnblog之初来乍到
查看>>
在win10中解决 你要以何方式打开此 .xlsx
查看>>
ajax hash缓存
查看>>
LeetCode——remove-duplicates-from-sorted-list
查看>>