Short類的java.lang.Short.floatValue()方法是Java中的內置方法,用於將Short對象的值作為浮點數返回。
用法:
public float floatValue()
返回類型:它返回ShortObject的值作為float。
下麵是Java中floatValue()方法的實現:
示例1:
// Java code to demonstrate
// Short floatValue() method
class GFG {
public static void main(String[] args)
{
// Short value
Short a = 17;
// wrapping the Short value
// in the wrapper class Short
Short b = new Short(a);
// floatValue of the Short Object
float output = b.floatValue();
// printing the output
System.out.println("Float value of "
+ a + " is : " + output);
}
}
輸出:
Float value of 17 is : 17.0
示例2:
// Java code to demonstrate
// Short floatValue() method
class GFG {
public static void main(String[] args)
{
String value = "17";
// wrapping the Short value
// in the wrapper class Short
Short b = new Short(value);
// floatValue of the Short Object
float output = b.floatValue();
// printing the output
System.out.println("Float value of "
+ b + " is : " + output);
}
}
輸出:
Float value of 17 is : 17.0
相關用法
- Java Shorts.indexOf(short[] array, short[] target)用法及代碼示例
- Java Shorts.indexOf(short[] array, short target)用法及代碼示例
- Java BigInteger floatValue()用法及代碼示例
- Java Integer floatValue()用法及代碼示例
- Java DoubleAdder floatValue()用法及代碼示例
- Java AtomicInteger floatValue()用法及代碼示例
- Java LongAccumulator floatValue()用法及代碼示例
- Java AtomicLong floatValue()用法及代碼示例
- Java LongAdder floatValue()用法及代碼示例
- Java DoubleAccumulator floatValue()用法及代碼示例
- Java Number.floatValue()用法及代碼示例
- Java BigDecimal floatValue()用法及代碼示例
- Java Byte floatValue()用法及代碼示例
- Java Short compare()用法及代碼示例
注:本文由純淨天空篩選整理自Sruti Rai大神的英文原創作品 Short floatValue() method in Java with Example。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。