林苡嫻w3schools,java雙迴圈,int整數,String字串,運算子operator

Java程式碼

/*林苡嫻2022/10/17 w3schools雙迴圈 運算子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,()空的,只有換列*/ } } }

截圖

截圖2

截圖3

留言

張貼留言

這個網誌中的熱門文章

林苡嫻tkinter視窗套件Entry工具代替OptionMenu工具

林苡嫻VSCode編輯Python, tkinter建構Button,Lable