吳崧晹w3school,Java雙迴圈,int整數,String子串,+串接,運算子operator

Java程式碼

/*劉任昌2022/10/17w3Schools學雙迴圈,運算子operator,運算元operand*/
public class Main {
  public static void main(String[] args) {
    int i, j;                    /*宣告整數integer變數i, j*/
    String a="第", b="列:";       /*宣告整數字串a, b給初始值*/
    for ( i = 0; i < 8; i++) {   /*迴圈*/
       System.out.print(a + i + b);/*+運算子用在字串,串接功能*/
       for ( j = 0; j <= i; j++)/*迴圈內僅有一道指令,可以不加{...}*/
          System.out.print(j);  /*print輸出完,下一個print在後面,*/
       System.out.println();    /*println輸出完換列line,()空的,只有換列*/
    }  
  }
}

w3schools程式碼截圖

/*吳崧晹2022/10/17w3Schools學雙迴圈,運算子operator,運算元operand*/ public class Main { public static void main(String[] args) { int i, j; /*宣告整數integer變數i, j*/ String a="第", b="列:"; /*宣告整數字串a, b給初始值*/ for ( i = 8; i > 0; i--) { /*迴圈*/ System.out.print(a + i + b);/*+運算子用在字串,串接功能*/ for ( j = 0; j <= i; j++)/*迴圈內僅有一道指令,可以不加{...}*/ System.out.print(j); /*print輸出完,下一個print在後面,*/ System.out.println(); /*println輸出完換列line,()空的,只有換列*/ } for ( i =40845; i < 40850; i ++)/*試探統一碼unicode 40845的對應字元*/ { a = Character.toString(i); /*Character字元.的toString轉成字串*/ System.out.println( i + " 字碼的字元是 " + a ); } System.out.println("統一碼unicode涵蓋地球上所有文字,當然涵蓋傳統的ascii美國標準資訊交換碼"); } }

留言

這個網誌中的熱門文章

程式碼註解

馬可維茲風險平均數平面