日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java valueof_Java Short类valueOf()方法及示例

發(fā)布時間:2025/3/11 java 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java valueof_Java Short类valueOf()方法及示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

java valueof

Syntax:

句法:

public static Short valueOf (short value);public static Short valueOf (String value);public static Short valueOf (String value, int radix's);

簡短的類valueOf()方法 (Short class valueOf() method)

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

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

  • valueOf(short value) method is used to represent Short object denoted by the given argument (value) is of short type.

    valueOf(short value)方法用于表示由給定參數表示的Short對象(value)是short類型。

  • valueOf(String value) method is used to represent Short object holding the short value denoted by the given argument (value) is of String type.

    valueOf(String value)方法用于表示Short對象,該對象持有由給定參數(值)表示的short值是String類型。

  • valueOf(String value, int radix's) method is used to represent a Short object holding the short value of the given argument (value) in the radix's given by the second argument.

    valueOf(String value,int radix's)方法用于表示一個Short對象,該對象持有第二個參數給定的基數中給定參數(值)的短值。

  • valueOf(short value) method does not throw an exception at the time of returning a Short instance.

    在返回Short實例時, valueOf(short value)方法不會引發(fā)異常。

  • Similarly, valueOf(String value), valueOf(String value, int radix's) method may throw a NumberFormatException at the time of returning an instance.

    同樣,在返回實例時, valueOf(String value) , valueOf(String value,int radix's)方法可能會引發(fā)NumberFormatException 。

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

    NumberFormatException :在此異常中,如果String不包含可解析的數字。

  • These methods are the static methods, it is 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.

    這些方法是靜態(tài)方法,也可以使用類名進行訪問,而且,如果嘗試使用類對象訪問這些方法,那么也不會出錯。

Parameter(s):

參數:

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

    在第一種情況下, short值 –表示short類型的值。

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

    在第二種情況下, 字符串值 –表示字符串類型的值。

  • In the third case, String value, int radix's – In this method first parameter value represents 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 Short – it returns the Short representation of this short argument.

在第一種情況下,此方法的返回類型為Short-它返回此short參數的Short表示形式。

In the second case, the return type of this method is Short – it returns the Short representation of this String argument.

在第二種情況下,此方法的返回類型為Short-它返回此String參數的Short表示形式。

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

在第三種情況下,此方法的返回類型為Short-它以第二個參數給定的基數形式返回String參數的Short表示形式。

Example:

例:

// Java program to demonstrate the example // of valueOf() method of Short classpublic class ValueOfShortClass {public static void main(String[] args) {short s1 = 100;short s2 = 200;short s3 = 40;short s4 = 20;// Object initializationShort ob1 = new Short(s1);Short ob2 = new Short(s2);Short ob3 = new Short(s3);// Display ob1,ob2,ob3 valuesSystem.out.println("ob1 :" + ob1);System.out.println("ob2 :" + ob2);System.out.println("ob3 :" + ob3);// It returns Short object holding the value // denoted by the given short argumentShort value1 = ob1.valueOf(s3);// String object initialization for valueOf(String s)String s = "80";// It returns Short object holding the value // denoted by the given String argumentShort value2 = ob2.valueOf(s);// It returns Short object holding the value // denoted by the given String argument with radix 20Short value3 = ob3.valueOf(s, s4);// Display result valuesSystem.out.println("ob1.valueOf(s3): " + value1);System.out.println("ob2.valueOf(s): " + value2);System.out.println("ob3.valueOf(s,s4): " + value3);} }

Output

輸出量

ob1 :100 ob2 :200 ob3 :40 ob1.valueOf(s3): 40 ob2.valueOf(s): 80 ob3.valueOf(s,s4): 160

翻譯自: https://www.includehelp.com/java/short-class-valueof-method-with-example.aspx

java valueof

總結

以上是生活随笔為你收集整理的java valueof_Java Short类valueOf()方法及示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。