

0. ์ค๋ฅ ๋ถ์
์ค๋ฅ ๋ฉ์์ง: not a statement
• Java ์ปดํ์ผ๋ฌ๋ Construct.PI;๋ฅผ ํ๋์ ๋ฌธ์ฅ(statement)์ผ๋ก ์ธ์ํ์ง ๋ชปํ๋ค.
• Construct.PI๋ double ํ์ ์ ์์๋ฅผ ๋ํ๋ด์ง๋ง,
์ฝ๋์์๋ ์๋ฌด ๋์๋ ํ์ง ์๊ณ ,
๊ฐ์ ํ์ฉํ์ง ์์๊ธฐ ๋๋ฌธ์ ์ปดํ์ผ๋ฌ๊ฐ ์ด๋ฅผ “๋ฌธ์ฅ์ด ์๋๋ค”๋ผ๊ณ ํ๋จํ๋ค.
๋ถ๋ชจ ํด๋์ค์ ํ๋๋ฅผ Main์ ๊ฐ์ ธ์์ผ๋ฉด ๋ฐ๋์ ๊ทธ๊ฒ์ด ์ฐ์ฌ์ผ ํ๋ค.
์ง๊ธ์ ์ฐ์ด์ง ์๋ ์ฝ๋์ด๋ฏ๋ก ์ค๋ฅ..
<Construct ํด๋์ค - public statia fianl ํ๋๋ก ์ด๊ธฐํ ๊ฐ ์ค์ >
package javaBasicLecture.final1;
public class Construct {
//์ํ ์์
public static final double PI = 3.14;
//์๊ฐ ์์
public static final int HOURS_IN_DAY = 24;
public static final int MINUTES_IN_HOUR = 60;
public static final int SECONDS_IN_MINUTE = 60;
//์ ํ๋ฆฌ์ผ์ด์
์ค์ ์์
public static final int MAX_USERS = 1000;
}
<Main ํด๋์ค - public static fianl ํ๋๋ฅผ ๋ถ๋ฌ์ค๊ธฐ. >
package javaBasicLecture.final1;
public class FinalLocalMain {
public static void main(String[] args) {
//final ํ๋ - ์์ฑ์ ์ด๊ธฐํ
System.out.println("์์ฑ์ ์ด๊ธฐํ");
ConstructInit constructInit1 = new ConstructInit(10);
ConstructInit constructInit2 = new ConstructInit(20);
System.out.println(constructInit1.value);
System.out.println(constructInit2.value);
//final ํ๋ - ํ๋ ์ด๊ธฐํ
System.out.println("ํ๋ ์ด๊ธฐํ");
FinalInit finalInit1 = new FinalInit();
FinalInit finalInit2 = new FinalInit();
FinalInit finalInit3 = new FinalInit();
System.out.println(finalInit1.value);
System.out.println(finalInit2.value);
System.out.println(finalInit3.value);
//์์
System.out.println("์์");
System.out.println(FinalInit.CONST_VALUE);
Construct.PI;
}
}
1. ์ ๋ฌธ์ ๊ฐ ๋๋๊ฐ?
Java์์ ๋ชจ๋ ์ฝ๋๋ ์ ํจํ ๋ฌธ์ฅ(statement)์ด์ด์ผ ํ๋ค.
• Construct.PI;๋ ์ด๋ค ์์ ๋ ์ํํ์ง ์์ผ๋ฉฐ,
๋จ์ํ ๊ฐ์ ์ฐธ์กฐํ๋ ๊ฒ์ผ๋ก ๋๋๊ธฐ ๋๋ฌธ์ ์ ํจํ์ง ์์ ๋ฌธ์ฅ์ผ๋ก ์ฒ๋ฆฌ๋๋ค.
2. ํด๊ฒฐ ๋ฐฉ๋ฒ

๋ฐ๋์ ๊ธฐ์กด์ ์จ์๋ Construct.PI;๋ ์ญ์ ํด์ฃผ๊ณ ์๋์ ๋์์๋ ์ฝ๋๋ฅผ ์ถ๊ฐ๋ก ์ฌ๋ ค์ผ ํ๋ค.
์๋ ํด๊ฒฐ์ฑ ์ ์ฝ๋๋ฅผ ์ ๋ ฅํ๋ค๊ณ ํด์ Construct.PI;๊ฐ ์ธ๋ชจ ์์ด์ง๋ ๊ฒ์ ์๋๋ค.
2.1 ๊ฐ์ ์ถ๋ ฅํ๊ฑฐ๋ ํ์ฉํ๊ธฐ
• Construct.PI๋ฅผ ์ถ๋ ฅํ๊ฑฐ๋ ๊ณ์ฐ์ ์ฌ์ฉํ๋ฉด ์ ํจํ ๋ฌธ์ฅ์ด ๋๋ค.
System.out.println(Construct.PI);
2.2 ๊ฐ์ ๋ณ์์ ์ ์ฅํ๊ธฐ
• Construct.PI๋ฅผ ๋ณ์์ ์ ์ฅํ๋ฉด ์ ํจํ ๋ฌธ์ฅ์ด ๋๋ค.
double piValue = Construct.PI;
System.out.println(piValue);
3. ์์ ๋ ์ฝ๋
public class FinalLocalMain {
public static void main(String[] args) {
System.out.println("PI ๊ฐ: " + Construct.PI); // ์์ PI ์ถ๋ ฅ
System.out.println("ํ๋ฃจ์ ์๊ฐ: " + Construct.HOURS_IN_DAY); // ๋ค๋ฅธ ์์ ํ์ฉ
}
}
๊ฒฐ๋ก
Construct.PI;๋ ๋จ์ํ ๊ฐ์ ์ฐธ์กฐํ๋ ๋ฌธ์ฅ์ด๋ฉฐ,
Java์์๋ ์ด๋ฐ ํํ๋ฅผ “์ ํจํ์ง ์์ ๋ฌธ์ฅ”์ผ๋ก ๊ฐ์ฃผํ๋ค.
์ด๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด Construct.PI๋ฅผ ์ถ๋ ฅํ๊ฑฐ๋ ๊ณ์ฐ, ๋ณ์ ์ ์ฅ ๋ฑ์ผ๋ก ํ์ฉํด์ผ ํ๋ค.