w3schools學習Java雙迴圈,整數int,字串String 10月 12, 2022

Java程式碼


  public class Main{                         /*楊盛閎2022/10/13德明C506教室*/
  public static void main(String[] args) {
    int i,j;                               /*宣告整數integer i,j */
    String a="第" , b="列:";               /*宣告字串a,b且設定值*/
    for ( i = 0; i < 12; i++) {            /*迴圈*/
      System.out.print(a+i+b);             /*字串用+連結*/
      for ( j = 0; j < i; j++)             /*從0開始;終點;改變量*/
      {
      System.out.print(j);                 /*迴圈內只有一指令,可不放{}*/
     System.out.print(' ');                /*函數或方法認System的out的print*/
    }
    System.out.println('.');               /*列印字串"."雙引號包起,都是String*/
  }
 }
}

w3school

aa

留言

這個網誌中的熱門文章

楊盛閎Python集合set清單list元組tuple字典dictionary 3月 26, 2023