Mega Code Archive

 
Categories / Java / Data Type
 

Convert a string to a number

public class Main {   public static void main(String[] argv) throws Exception {     byte b = Byte.parseByte("123");     short s = Short.parseShort("123");     int i = Integer.parseInt("123");     long l = Long.parseLong("123");     float f = Float.parseFloat("123.4");     double d = Double.parseDouble("123.4e10");   } }