When I do the first code I'm getting the following output (whereas it is expected to be something else). Now with a small change the result is different. Why is that?
CASE 1
package mydemo;
public class hw {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("HelloWorld");
        int x =10;
        int y =20;
        int result = x + y;
        System.out.println(" result");
    }
}
output:
HelloWorld
 result
CASE 2
package mydemo;
public class hw {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("HelloWorld");
        int x =10;
        int y =20;
        int result = x + y;
        System.out.println(" result = " + result);
    }
}
output
HelloWorld
 result = 30
 
     
     
     
    