주 메소드에서 isATens 메소드를 호출하려고하지만, isATens에 매개 변수가없는 경우에만이를 수행 할 수 있습니다. 나는 호출자와 동일한 매개 변수를 넣으려고했으나 그 중 하나를 인식하지 못합니다.main 메서드의 변수 매개 변수를 사용하여 메서드를 호출하는 방법은 무엇입니까?
public class P1L4 {
public static void main(String[] args) {
P1L4 main = new P1L4();
main.run();
isATens(userInput); //<--- this is what I've tried doing.
}
public void run() {
Scanner scanner = new Scanner(System.in);
System.out.println("Name a tens and i'll test if it's one under 100.");
int userInput = scanner.nextInt();
}
public boolean isATens(int userInput) {
System.out.println(userInput);
switch (userInput) {
case 10 : case 20 : case 30 : case 40 : case 50 : case 60: case 70: case 80: case 90 :
isUnderOneHundred(continued);
default :
System.out.println("Not under one hundred");
}
return true;
}
public boolean isUnderOneHundred(int continued) {
return true;
}
}
userInput은 변수가 아니며, isATens (5) 또는 isATens ()를 사용하여 value.try도 아닙니다. 또한 isATens는 정적 메서드가 아니기 때문에 클래스 –
Stultuske
의 인스턴스를 통해 호출해야하며 main.isAtens (5)를 호출해야합니다. isUnderOneHundred 메소드는 무의미합니다. 'run' 메쏘드에' – pecks
:'Scanner'를 읽은 후'isAtens (userInput)'. – AxelH