package ex01.Printf;
public class MainEntry___ {
public static void main(String[] args) {
System.out.printf("\n\n\n%10.1f\n", 12.34);
System.out.printf("%3.1f\n", 12345.34789);
System.out.printf("%.2f\n", 12345.34789);
System.out.printf("메시지 출력 : %.10f\n", 12345.34789); //**
System.out.printf("메시지 출력2 : %.15f\n", 12345.3478987654); //**
}
}
//제어문자 : \문자 - \n, \t, \a,.....
//printf() - 서식에 맞춰서 출력 : %문자 - %c, %s, %d, %i, %f,...
12.3
12345.3
12345.35
메시지 출력 : 12345.3478900000 ->%.10f는 소수점 10자리까지 출력하라는 뜻
메시지 출력2 : 12345.347898765400000 ->%.15f는 소수점 15자리까지 출력하라는 뜻
'JAVA > 02_기본 구문' 카테고리의 다른 글
클래스 변수 / 지역 변수 (0) | 2021.01.11 |
---|---|
Identifier Definition Rule / 변수 (0) | 2021.01.10 |
printf (0) | 2021.01.10 |
print / println / printf (0) | 2021.01.10 |
Hello Java! (0) | 2021.01.10 |