How to assign multiple values to multiple variables in one line with Java

1 Answer

0 votes
class MultipleVariablesOneLine {
    public static void main(String[] args) {
        int a = 1, b = 2, c = 3, d = 4;
        
        System.out.println(a + " " + b + " " + c + " " + d);
    }
}



/*
run:

1 2 3 4

*/

 



answered Jul 7, 2024 by avibootz
...