public class Main
{
public static void main(String[] args) {
System.out.println("Hello World 1st code ");
return;
System.out.println("Hello World 2nd code ");
}
}
public class Main
{
public static void do_something(int i)
{
System.out.println(" i : "+i);
// break the method
/// System.exit(0); // stop all the program
/// return; // Main.java:20: error: unreachable statemen
if(true) return;
// do some computing
int res = i*i;
System.out.println(" res : "+res);
}
public static void main(String[] args) {
for (int i = 0; i <5; i++)
{
do_something(i);
}
System.out.println("Ouiiiii , work finished ");
}
}
结果是:
i : 0
i : 1
i : 2
i : 3
i : 4
Ouiiiii , work finished