์ปดํ์ผ ์๋ฌ (Compile-time Error)
| ๋ฐ์ ์์ |
์ฝ๋๋ฅผ ์ปดํ์ผํ ๋ (javac) |
| ์์ธ |
๋ฌธ๋ฒ ์ค๋ฅ, ํ์
๋ถ์ผ์น, ์๋ชป๋ ์ฐธ์กฐ ๋ฑ |
| ํน์ง |
ํ๋ก๊ทธ๋จ์ด ์คํ์กฐ์ฐจ ์ ๋จ |
| ์ |
๋ฌธ๋ฒ ์ค๋ฅ(Syntax Error), ํด๋์ค/๋ฉ์๋ ๋ฏธ์กด์ฌ, ํ์
๋ถ์ผ์น ๋ฑ |
public class CompileErrorExample {
public static void main(String[] args) {
int number = "123"; // โ ๋ฌธ์์ด์ int์ ๋ฃ์ ์ ์์ (ํ์
๋ถ์ผ์น)
}
}
error: incompatible types: String cannot be converted to int
๋ฐํ์ ์๋ฌ (Runtime Error)
| ๋ฐ์ ์์ |
ํ๋ก๊ทธ๋จ ์คํ ์ค (java ๋ช
๋ น์ผ๋ก ์คํํ ๋) |
| ์์ธ |
์์ธ(Exception) ๋ฐ์, ๋
ผ๋ฆฌ ์ค๋ฅ, ์๋ชป๋ ์
๋ ฅ ๋ฑ |
| ํน์ง |
์ปดํ์ผ์ ์ฑ๊ณตํ์ง๋ง, ์คํ ์ค์ ํฌ๋์(์์ธ) ๋ฐ์ |
| ์ |
NullPointerException, ArithmeticException, ArrayIndexOutOfBoundsException ๋ฑ |
public class RuntimeErrorExample {
public static void main(String[] args) {
String text = null;
System.out.println(text.length()); // โ NullPointerException
}
}
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.length()" because "text" is null
| ๋ฐ๊ฒฌ ์์ |
์ปดํ์ผ ์์ (javac) |
์คํ ์์ (java) |
| ์์ |
๋ฌธ๋ฒ ์ค๋ฅ, ์๋ชป๋ ํ์
|
0์ผ๋ก ๋๋, null ์ ๊ทผ ๋ฑ |
| ํ๋ก๊ทธ๋จ ์คํ ์ฌ๋ถ |
์คํ๋์ง ์์ |
์คํ๋์ง๋ง ์ค๊ฐ์ ๋ฉ์ถค |