File tree 5 files changed +59
-5
lines changed
CCVT_Code_Distribute/src/com/rt
5 files changed +59
-5
lines changed Original file line number Diff line number Diff line change
1
+ package com .rt .anonomousclass ;
2
+
3
+ public interface Greeting {
4
+
5
+ public void print ();
6
+
7
+ }
Original file line number Diff line number Diff line change
1
+ package com .rt .anonomousclass ;
2
+
3
+ public class Temp implements Greeting {
4
+
5
+ @ Override
6
+ public void print () {
7
+ // TODO Auto-generated method stub
8
+ System .out .println ("Hello World" );
9
+ }
10
+
11
+
12
+ }
Original file line number Diff line number Diff line change
1
+ package com .rt .anonomousclass ;
2
+
3
+ public class TestClass {
4
+
5
+ public static void main (String [] args ) {
6
+ // TODO Auto-generated method stub
7
+
8
+ System .out .println ("Hello" );
9
+
10
+ Greeting obj =new Greeting (){
11
+
12
+ @ Override
13
+ public void print () {
14
+ // TODO Auto-generated method stub
15
+ System .out .println ("Hello World" );
16
+
17
+ }
18
+ };
19
+
20
+ obj .print ();
21
+
22
+ }
23
+
24
+ }
Original file line number Diff line number Diff line change @@ -57,7 +57,17 @@ protected Employee clone() throws CloneNotSupportedException {
57
57
58
58
return temp ;
59
59
}
60
-
60
+ @ Override
61
+ public boolean equals (Object obj ) {
62
+ // TODO Auto-generated method stub
63
+ Employee temp =(Employee ) obj ;
64
+ if (this .getEid ()==temp .getEid ())
65
+ return true ;
66
+ else
67
+ return false ;
68
+
69
+ // return super.equals(obj);
70
+ }
61
71
62
72
63
73
Original file line number Diff line number Diff line change @@ -13,18 +13,19 @@ public static void main(String[] args) throws CloneNotSupportedException {
13
13
Employee e2 = e1 .clone ();
14
14
15
15
16
-
17
16
System .out .println (e1 );
18
17
System .out .println (e2 );
19
- e2 .setEid (3 );
18
+ // e2.setEid(3);
20
19
e2 .setEname ("Shyam" );
21
20
e2 .getDep ().setDid (8 );
22
21
e2 .getDep ().setDname ("Acc" );
23
22
System .out .println (e1 );
24
23
System .out .println (e2 );
25
-
24
+ //new Employee().getEid();
26
25
System .out .println (e1 instanceof Cloneable );
27
-
26
+ System .out .println (e1 .clone ()!=e1 );
27
+ System .out .println (e2 .getClass ()==e1 .getClass ());
28
+ System .out .println (e1 .equals (e2 ));
28
29
}
29
30
30
31
}
You can’t perform that action at this time.
0 commit comments