2012-02-12 6 views
0

이 코드를 가지고 컴파일하려고했습니다. 하지만 나에게 준오류 : 기호를 찾을 수 없습니다. 기호 : 변수 keyBoard

error: cannot find symbol

anotherEntry = keyBoard.nextInt();

symbol: variable keyBoard

location: class DemoVariables3

실마리는 무엇입니까?

코드 :

당신은 keyBoard라는 변수를 생성하고 변수 keyBoard 사용하여 시도하기 전에 새로운 Scanner 객체에 할당해야
import java.util.Scanner; 

public class DemoVariables3 
{ 
public static void main(String[] args) 
    { 
    int entry; 
    int anotherEntry; 
    System.out.print("Enter another integer "); 
    anotherEntry = keyBoard.nextInt(); 
    System.out.print("The other entry is "); 
    System.out.println(anotherEntry); 
    System.out.println(entry + "plus" + 
    anotherEntry + "is" + (entry + anotherEntry)); 
    } 
} 

답변

1

:

Scanner keyBoard = new Scanner(System.in); 
+0

잘 했어! 감사! – ultra99

관련 문제