1. printf 형식에 println 입력
오류 메시지
Exception in thread "main" java.lang.Error: Unresolved compilation problem: the method println(int) in the type PrintStream is not applicable for the arguments (String, int)
코드
System.out.println("음악을 %d번 재생했습니다.\n", ++count);
해결
(" ", )형식은 printf에서 사용한다.
printf(" ", )
println()
2. System.out.println에서 out 미입력
오류 메시지
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method println(String) is undefined for the type System
코드
System.println("반복 종료");
해결
System.out.println("반복 종료");
3. if문 조건식 미입력
오류 메시지
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error on token "(", Expression expected after this token
코드
if()
{
System.out.println("다시 입력해주세요.");
continue;
}
해결
if() 안에 조건식을 입력한다.
4. System을 system으로 입력
오류 메시지
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
system cannot be resolved to a variable
코드
sc = new Scanner(system.in);
해결
sc = new Scanner(System.in);
java는 대문자와 소문자를 구별한다.
Scanner와 String, System 등 대문자로 써야 하는 것에는 주의한다.
5. 불필요한 .
오류 메시지
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error on token ".", Identifier expected after this token
코드
Scanner sc;
sc = new Scanner.(System.in);
해결
new Scanner(System.in);
'오류노트' 카테고리의 다른 글
[코딩 오류 노트] 클래스, 인스턴스, 메서드 (0) | 2023.10.17 |
---|---|
[코딩 오류 노트] 배열 선언 실수, 배열 인덱스 범위 초과 (0) | 2023.10.16 |
[코딩 오류 노트] 제어문과 외부 클래스 연결 (0) | 2023.10.12 |
[코딩 오류 노트] 변수 이름 중복, 데이터 타입, 자동 형 변환, 상수 선언 후 값 변경 등 (0) | 2023.10.11 |
[코딩 오류 노트] ; 미기입 (0) | 2023.10.10 |