Java variable definition error 2

Question

Identify and fix the errors in the following code

public class Main {
   public static void main(String[] args) {
      int i = j = k = 2;
      System.out.println(i + " " + j + " " + k);
   }
}


To define three int type variables, use the following code
int i =2, j =2, k = 2;
public class Main {
   public static void main(String[] args) {
      int i =2, j =2, k = 2;
      System.out.println(i + " " + j + " " + k);
   }/*from  w w  w  .j  a  v a 2  s .com*/
}



PreviousNext

Related