⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 运算符和语句.txt

📁 适合初学者练习 包括awt小程序、list和map群体等100多个java程序
💻 TXT
字号:
运算符和语句 List.1 Switcher/Switcher.java 
运算符和语句 List.2 WhileCount/WhileCount.java 
运算符和语句 List.3 DoWhileCount/DoWhileCount.java 
运算符和语句 List.4 ForCount/ForCount.java 
运算符和语句 List.5 LabelDemo/LabelDemo.java 

--------------------------------------------------------------------------------

运算符和语句 List.1 Switcher/Switcher.java 
Return to top 
001: class Switcher {
002:  public static void main(String args[]) {
003:   int a = 2;
004:   switch (a) {
005:    case 1:
006:     System.out.println("Case 1");
007:     break;
008:    case 2:
009:     System.out.println("Case 2");
010:     System.out.println("Final statement in case 2");
011:     break;
012:    case 3:
013:     System.out.println("Case 3");
014:     break;
015:    default:
016:     System.out.println("All other cases");
017:   }
018:  }
019: }

Return to top 
--------------------------------------------------------------------------------

运算符和语句 List.2 WhileCount/WhileCount.java 
Return to top 
001: class WhileCount {
002:  public static void main(String args[]) {
003:   int count = 0;
004:   while (count < 10) {
005:    count++;
006:    System.out.println("Count = " + count);
007:   }
008:  }
009: }

Return to top 
--------------------------------------------------------------------------------

运算符和语句 List.3 DoWhileCount/DoWhileCount.java 
Return to top 
001: class DoWhileCount {
002:  public static void main(String args[]) {
003:   int count = 0;
004:   do {
005:    count++;
006:    System.out.println("Count = " + count);
007:   } while (count < 10);
008:  }
009: }

Return to top 
--------------------------------------------------------------------------------

运算符和语句 List.4 ForCount/ForCount.java 
Return to top 
001: class ForCount {
002:  public static void main(String args[]) {
003:   int count;
004:   for (count = 1; count <= 10; count++) {
005:    System.out.println("Count = " + count);
006:   }
007:  }
008: }

Return to top 
--------------------------------------------------------------------------------

运算符和语句 List.5 LabelDemo/LabelDemo.java 
Return to top 
001: class LabelDemo  {
002:  public static void main(String args[]) {
003:   int i, j;
004: OuterLoop:
005:   for (i = 1; i < 100; i++) {
006:    System.out.println("/nOuter loop # " + i);
007: InnerLoop:
008:    for (j = 1; j < 10; j++) {
009:     if (j % 2 == 0)
010:      continue InnerLoop;  // Skip even j values
011:     if (i > 4)
012:      break OuterLoop;     // Abort if i > 4
013:     System.out.println("j = " + j);
014:    }  // end of inner for statement
015:   }   // end of outer for statement
016:    System.out.println("Program exiting at OuterLoop:");
017:  }    // end of main() method
018: }     // end of class declaration

Return to top 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -