728x90
ing ~
What ?
Error
💡개발 시 발생하는 프로그램의 에러입니다.
💡 상황에 따른 에러를 세분화해놓으면 개발효율이 높아집니다.
IDE
💡 Reference Error
// 단어오타가 있을 경우
consle.log("Hello");
💡 Syntax Error
// 기호오타가 있을 경우
console.log("Hello);
💡 list should have a unique "key" prop
// key가 식별가능한 유일성을 가지지 못한 경우
const ExampleList = [
{name: "yi"},
{name: "jo"}
];
...
{ExampleList?.map((item)=>{
<ul key={new Date()}>
<li>{item?.name}</li>
</ul>
}
)
}
Reference Error : example is not defined : 정의되지 않은 변수에 접근 시 발생.
console.log(example);
Type mismatch : 올바르지 않은 자료형 타입으로 변수를 선언 시 발생
public static void main(String[] args) {
byte test1 = 20;
byte test2 = 10;
byte test3 = 0;
test3 = test1 + test2; // Type mismatch: cannot convert from int to byte
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException : 인덱스가 배열보다 크거나 음수일 때
class Solution {
public long[] solution(long x, int n) {
long[] answer = {}; // 배열을 제대로 선언 long[] answer = new long[n];
for (int i = 0; i < n; i++) {
answer[i] = x * (i + 1);
}
return answer;
}
}
class solution {
public int[] solution(int x) {
int[] arr = {0, 1, 2, 3, 4};
arr[5] = 4; // 5번째 index는 존재하지 않아 에러 발생
}
Unreahable code : return 문 이후에 실행문을 실행한 경우
int plus(int x, int y){
int result = x + y;
return result;
result ++; // return 문 뒤에 실행하여 오류 발생
}
ArithmeticException : 연산 시 나누기 0 을 한 경우
public static void main(String[] args) {
int result = 10 / 0;
}
The local variable value may not have been initailized : 초기화되지 않은 변수 사용 시
public class Example{
int score;
System.out.println(score);
}
728x90
'Other > Programming' 카테고리의 다른 글
for 문 (0) | 2022.07.28 |
---|---|
식별자 (1) | 2022.07.25 |
Programming (0) | 2022.07.25 |
trim( ) (0) | 2022.07.23 |
split( ) (0) | 2022.07.22 |