vendredi 17 février 2017

Why if condition cannot be written out side the method in a class in JAVA

See the following code:

public class example {
    int i=0; 
    public static void main(String []str)
    {
        System.out.println("inside main"); 
    } 
    if(1==1) System.out.println("hello");
}

In this code, if I move the if condition inside the method, then it works properly. can anybody answer why the if condition won't work outside the method?

Aucun commentaire:

Enregistrer un commentaire