java编译变量的正确写法和控制台输入
一些变量的正确写法:
short s = 123;
int i = 50000; 隐式转换
byte b = (byte)200;
long l = 88888888888l;
float f = 12.345f;显式转换
int b;
b = (int)(b + 0.3);
1 控制台输入: 2 import java.util.Scanner; 3 public class TestScanner{ 4 public static void main(String[] args){ 5 Scanner scanner = new Scanner(System.in); 6 String str = scanner.nextLine(); 7 int a = Integer.parseInt(str); 8 if(a>=90){ 9 System.out.println("优秀"); 10 }else if(a>=60&a<90){ 11 System.out.println("及格"); 12 }else{ 13 System.out.println("不及格"); 14 } 15 scanner.close(); 16 } 17 }