티스토리 뷰
printf()를 이용해서 구구단 출력해보기
public class PrintfAndPrintln {
public static void main(String[] args) {
System.out.print(" | ");
for(int i = 1; i < 9; i++) {
System.out.printf("%3d",i);
}
System.out.println("\n --+--------------------------");
for(int i=1; i<9;i++) {
System.out.printf("%2d | ",i);
for(int j=1;j<9;j++)
System.out.printf("%3d",i*j);
System.out.println();
}
}
}
※ printf() 감잡기
'Java' 카테고리의 다른 글
[JSP]req.getParameter와 req.setAttribute (0) | 2023.04.24 |
---|---|
[오류]Multiple annotations found at this line (0) | 2023.03.19 |
[JAVA] printf 1 (0) | 2023.03.03 |
[JAVA] 객체지향 프로그래밍 2 (0) | 2023.02.27 |
[JAVA]객체지향 프로그래밍 1 (0) | 2023.02.27 |