java类型转换

//java类型转换
public class Demo2 { public static void main(String[] args){ int num1 = 55; int num2 =77; String str3 = "12355588"; String str4 = "12345222"; long lnum5 = 123991122; long lnum6 = 99121222; //int->string String result1 = Integer.toString(num1)+Integer.toString(num2); System.out.println("int->string:num1+num2="+result1); //long->int int result2 = (int)lnum5+(int)lnum6; System.out.println("long->int:lnum5+lnum6="+result2); //long->string String result3 = Long.toString(lnum5)+Long.toString(lnum6); System.out.println("long->string:lnum5+lnum6="+result3); //string->int int result4 = Integer.parseInt(str3)+Integer.valueOf(str4).intValue(); System.out.println("string->int:str3+str4="+result4); //string->long long result5 = Long.parseLong(str3)+Long.valueOf(str4); System.out.println("string->long:str3+str4="+result5); }

  

你可能感兴趣的:(java)