public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String s = scanner.nextLine();
//equals:判断字符串是否相等
if (s.equals("hello")){
System.out.println("hello");
}
System.out.println("end");
scanner.close();
}
public static void main(String[] args) {
//考试分数大于60就是及格,小于60分就不及格。
Scanner scanner = new Scanner(System.in);
System.out.println("请输入成绩");
int score = scanner.nextInt();
if (score>=60){
System.out.println("及格");
}else {
System.out.println("不及格");
}
scanner.close();
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int score = scanner.nextInt();
if (score==100){
System.out.println("恭喜你满分");
}else if (score<100 && score>=90){
System.out.println("你的成绩为A");
}else if (score<90 && score>=80){
System.out.println("你的成绩为B");
}
else if (score<80 && score>=70){
System.out.println("你的成绩为C");
}
else if (score<70 && score>=60){
System.out.println("你的成绩为D");
}else if (score<60 && score>=0){
System.out.println("你的成绩不合格");
}else System.out.println("成绩不合法");
scanner.close();
}
public static void main(String[] args) {
String name = "景云飞";
//JDK7的新特性,表达式结果可以是字符串!!!
//字符的本质还是数字
//反编译 java---class(字节码文件)---反编译(IDEA)从文件夹中复制过去
switch (name){
case "景云飞":
System.out.println("景云飞");
break;
case "哈哈":
System.out.println("哈哈");
break;
default:
System.out.println("黑子");
}
}
原文:https://www.cnblogs.com/jinghaha/p/15305932.html