Java variable definition error 1

Question

Identify and fix the errors in the following code

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


k is not defined
public class Main { 
   public static void main(String[] args) {
      int k = 1;//from w w w. j  a  v a2 s . co  m
      int i = k + 2; 
      System.out.println(i); 
   } 
} 



PreviousNext

Related