IT/java

printf, println, print 차이

SHLEE™ 2017. 5. 22. 13:59

System.out.printf("%-4s %c %3d \n", "둘리" , 'A', 12);

//String type : 왼쪽 4자리수 정렬

//char type : 출력

//int type : 3자리수 정렬

//서식 형태의 자료 출력


System.out.println("둘리 A 12");

//직관적 출력뒤 줄바꿈


System.out.print("둘리 A 12\n");

//직관적 출력 줄바꿈 \n 입력


<출력>

둘리   A  12

둘리 A 12

둘리 A 12