Java Short parseShort Example
Short class parseShort method example. This example shows you how to use parseShort method.
Short class parseShort method example. This example shows you how to use parseShort method. This is static method.
Here is the code.
/** @(#) ParseShortShort.java
* A class representing use of method parseShort() of Short class in java.lang Package.
* @Version 03-May-2008
* @author Rose India Team
*/
class ParseShortShort{
public static void main(String[] args){
String str = "1001";
//This is static method.
//Method returns signed decimal short value of String argument.
short shortValue = Short.parseShort(str);
System.out.println("Signed decimal short value for specified String is : " + shortValue);
//Method returns the string argument as a signed short in the radix specified by the second argument.
shortValue = Short.parseShort(str,2);
System.out.println("Signed decimal short value for specified String with radix 2 is : " + shortValue);
shortValue = Short.parseShort("11",8);
System.out.println("Signed decimal short value for specified String with radix 8 is : " + shortValue);
}
} |
null
|