-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExample3.java
More file actions
57 lines (42 loc) · 808 Bytes
/
Copy pathExample3.java
File metadata and controls
57 lines (42 loc) · 808 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//final keyword
//created final class we cannot modify this class
final class Test
{
public void f1()
{System.out.println("hello from Test class ");}
}
//create a final function we cannot modify this function or override
class d
{
public final void f1()
{
System.out.println("Hello world");
}
}
public class Example3
{
private final int x; //final instance member variable
private final static int y; // final static member variable
//static initialization block
static
{
y = 5;
}
//constructor
Example3()
{
x = 10;
}
public void fun()
{
final int a; //final local variable
System.out.println("fun from Example3 class ");
}
public static void main(String []args)
{
Example3 e1 = new Example3();
e1.fun();
Test t1 = new Test();
t1.f1();
}
}