- package com.ruqi.keybox;
- public class InputWord {
- public static void main(String[] args) {
- int sorce = 99;
- // if(表达式){程序},大括号可不填
- if (sorce == 99) {
- System.out.println("您的分数为" + sorce);
- }
-
- //if(表达式){程序}else{程序}
- if (sorce > 99) {
- System.out.println("您的分数大于99");
- }
- else {
- System.out.println("您的分数不大于99");
- }
- // if(表达式){程序}else if表达式){程序}else
- if (sorce > 99) {
- System.out.println("您的分数大于99");
- }
- else if(sorce == 99){
- System.out.println("您的分数等于" + sorce);
- }
- else{
- System.out.println("您的分数不满足要求");
- }
- }
- }
- // case不支持double,float,long类型
- public class SwitchDemo {
- public static void main(String[] args) {
- String weekday = "周一";
- switch (weekday){
- case "周一" :
- System.out.println("今天是周一");
- break;
- case "周二" :
- System.out.println("今天是周二");
- break;
- case "周三" :
- System.out.println("今天是周三");
- break;
- default:
- System.out.println("今天是周四");
- }
- }
- }
-
- public class ForDemo2 {
- public static void main(String[] args) {
- //输出三次hello
- for (int i = 0; i < 3 ; i+=1){
- System.out.println("hello");
- }
- }
- }
- public class WhileDemo {
- public static void main(String[] args) {
- int i = 1;
- while (i < 3){
- System.out.println("hello");
- i++;
- }
- }
- }
- public class WhileDemo {
- public static void main(String[] args) {
- int i = 0;
- do{
- System.out.println("hello");
- i++;
- }while (i < 3);
- }
- }