复习知识

String转基本数据类型
String a = "123";
int b = Integer.parseInt(a);
System.out.println(b);
long c = Long.parseLong(a) ;

float d = Float.parseFloat(a);

基本数据类型转String

int  x= 123;
String y = String.valueOf(x+1);
System.out.println(y);

Scanner scanner = new Scanner(System.in);
System.out.println("请输入一个数字:");
        int a = scanner.nextInt();
int c = a*2+100;
System.out.println(c);


System.out.println("请输入你的名字:");
String name = scanner.next();
System.out.println("请输入你的年龄:");
int d = scanner.nextInt();
System.out.println("姓名:"+name+" 年龄: "+d+"岁");

你可能感兴趣的:(复习知识)