-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDemoBlock.java
More file actions
39 lines (29 loc) · 1019 Bytes
/
Copy pathDemoBlock.java
File metadata and controls
39 lines (29 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
public class DemoBlock
{
public static void main(String[] args)
{
System.out.println("Demonstrating block scope");
int x = 1111;
System.out.println("In first block x is " + x);
{
int y =222;
System.out.println("In second block x is " +x);
System.out.println("In second block y is " +y);
}
{
int y = 3333;
System.out.println("In third block x is " +x);
System.out.println("In third block y is " +y);
demoMethod();// method changes x online once. Cool.
System.out.println("After method x is " +x);
System.out.println("After method block y is " +y);
}
System.out.println("At the end x is " +x);
}
public static void demoMethod()
{
int x = 8888, y = 9999;
System.out.println("In demoMethod x is " +x);
System.out.println("In demoMethod block y is " +y);
}
}