/* Using break as a Goto satement:
Java doesnot have a goto statement, so we use break inted of Goto statement
*/
class Goto
{
public static void main(String args[])
{
boolean t=true;
first: {
second: {
third: {
System.out.println("Before Break Statement");
if(t) break second; // break out of the second block
System.out.println("This line won't execute");
}
System.out.println("This line won't execute");
}
System.out.println("This is after second block");
}
}
}
Java doesnot have a goto statement, so we use break inted of Goto statement
*/
class Goto
{
public static void main(String args[])
{
boolean t=true;
first: {
second: {
third: {
System.out.println("Before Break Statement");
if(t) break second; // break out of the second block
System.out.println("This line won't execute");
}
System.out.println("This line won't execute");
}
System.out.println("This is after second block");
}
}
}
No comments:
Post a Comment