public class Block
{
public static void main(String args[])
{
int x=10;
blk1: //label 
{//start of block1
int y=50;
System.out.println("Inside Block -1");
System.out.println("X: "+x);
System.out.println("Y: "+y);
}//end of block1

blk2:
{//start of block2
int y=20;
int x=30;//conflict with x in main
System.out.println("Inside Block -2");
System.out.println("X: "+x);
System.out.println("Y: "+y);
}//end of block1

System.out.println("Outside the block: X is:"+x);
}//end of main()
}//end class block.





Watch Video

No comments

Post your comments

Powered by Blogger.