#Need to declare multiple input statements in a single line in java.

4 messages · Page 1 of 1 (latest)

forest dew
#
public class gcd {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String[] input = new String[2];
        int a;
        int b;

        System.out.println("Enter the first number: ");

        String[] input = sc.nextInt(); //error on this line
        a = Integer.parseInt(input[0]);
        b = Integer.parseInt(input[1]);

    }
}
weak reefBOT
#

This post has been reserved for your question.

Hey @forest dew! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

forest dew