0

Is there any possibility in java when I type in the console 26 via scanner input that it automatically fills up t2 and t3 with their respective values in an if statement? (t2 should be 3 and t3 should be 2020)

        Scanner in = new Scanner(System.in);         
        String s = in.nextLine(); 

        int t = Integer.parseInt(s);

        System.out.println((Arrays.asList(t, t2, t3)));


1 Answer 1

2

I'm not entirely sure about your question. Is this what you ask for?

    Scanner in = new Scanner(System.in);         
    String s = in.nextLine(); 

    int t = Integer.parseInt(s);

    if (t == 26) {
        t2 = 3; // assumed that t2 and t3 are int
        t3 = 2020;
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.