문제

import java.util.Scanner;

public class Fernando {
    public static void main(String[] args) {
        Scanner skype = new Scanner(System.in);
        System.out.print("What is your name ")?
        String n = skype.nextLine(); // This is the line with the error
        System.out.print("\n and how old are you?");
        int y = skype.nextInt();
        displayInfo(n,y);
    }

    public String displayInfo(String name, int age){
        return name +" is "+ age+" years old.";
    }
}

All it says is expected. I don't understand what's wrong at all.

도움이 되었습니까?

해결책

Try changing

System.out.print("What is your name ")?

to:

System.out.println("What is your name?");

This should work, as you have a ? instead of a ;.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top