Convert Short to byte, double, float, int, long and short
byte byteValue()
- Returns the value of this Short as a byte.
double doubleValue()
- Returns the value of this Short as a double.
float floatValue()
- Returns the value of this Short as a float.
int intValue()
- Returns the value of this Short as an int.
long longValue()
- Returns the value of this Short as a long.
short shortValue()
- Returns the value of this Short as a short.
public class Main {
public static void main(String[] args) {
Short shortObject = new Short("10");
byte b = shortObject.byteValue();
System.out.println("byte:"+b);
short s = shortObject.shortValue();
System.out.println("short:"+s);
int i = shortObject.intValue();
System.out.println("int:"+i);
float f = shortObject.floatValue();
System.out.println("float"+f);
double d = shortObject.doubleValue();
System.out.println("double:"+d);
long l = shortObject.longValue();
System.out.println("long:"+l);
}
}
The output:
byte:10
short:10
int:10
float10.0
double:10.0
long:10
Home
Java Book
Essential Classes
Java Book
Essential Classes
Short:
- Short class
- Find out the min value, max value and size of Short types
- Create Short object with its constructor
- Convert Short to byte, double, float, int, long and short
- Decode a string to short value
- Convert string to a short value
- Reverse the bytes in a short
- Convert short value to string
- Compare two short values