File tree Expand file tree Collapse file tree
main/java/com/baeldung/reflection
test/java/com/baeldung/reflection Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 <artifactId >maven-compiler-plugin</artifactId >
1313 <version >3.3</version >
1414 <configuration >
15- <source >7 </source >
16- <target >7 </target >
15+ <source >8 </source >
16+ <target >8 </target >
1717 </configuration >
1818 </plugin >
1919 </plugins >
Original file line number Diff line number Diff line change 11package com .baeldung .reflection ;
22
3- public abstract class Animal implements Eating {
4- public static final String CATEGORY = "domestic" ;
5- private String name ;
3+ public abstract class Animal implements Eating {
64
7- public Animal (String name ) {
8- this .name = name ;
9- }
5+ public static final String CATEGORY = "domestic" ;
106
11- public String getName () {
12- return name ;
13- }
7+ private String name ;
148
15- public void setName (String name ) {
16- this .name = name ;
17- }
9+ public Animal (String name ) {
10+ this .name = name ;
11+ }
1812
19- public String makeSound () {
20- return getSound () ;
21- }
13+ public String getName () {
14+ return name ;
15+ }
2216
23- protected abstract String getSound ();
17+ public void setName (String name ) {
18+ this .name = name ;
19+ }
20+
21+ public String makeSound () {
22+ return getSound ();
23+ }
24+
25+ protected abstract String getSound ();
2426
2527}
Original file line number Diff line number Diff line change 11package com .baeldung .reflection ;
22
33public class Bird extends Animal {
4- private boolean walks ;
5- public Bird () {
6- super ("bird" );
7- }
8- public Bird (String name , boolean walks ) {
9- super (name );
10- setWalks (walks );
11- }
12- public Bird (String name ) {
13- super (name );
14- }
15-
16- @ Override
17- public String eats () {
18- return "grains" ;
19- }
20-
21- @ Override
22- protected String getSound () {
23- return "chaps" ;
24- }
25-
26- public boolean walks () {
27- return walks ;
28- }
29-
30- public void setWalks (boolean walks ) {
31- this .walks = walks ;
32- }
4+ private boolean walks ;
5+
6+ public Bird () {
7+ super ("bird" );
8+ }
9+
10+ public Bird (String name , boolean walks ) {
11+ super (name );
12+ setWalks (walks );
13+ }
14+
15+ public Bird (String name ) {
16+ super (name );
17+ }
18+
19+ @ Override
20+ public String eats () {
21+ return "grains" ;
22+ }
23+
24+ @ Override
25+ protected String getSound () {
26+ return "chaps" ;
27+ }
28+
29+ public boolean walks () {
30+ return walks ;
31+ }
32+
33+ public void setWalks (boolean walks ) {
34+ this .walks = walks ;
35+ }
3336}
Original file line number Diff line number Diff line change 11package com .baeldung .reflection ;
22
33public interface Eating {
4- String eats ();
4+ String eats ();
55}
Original file line number Diff line number Diff line change 11package com .baeldung .reflection ;
22
3- public class Goat extends Animal implements Locomotion {
3+ public class Goat extends Animal implements Locomotion {
44
5- public Goat (String name ) {
6- super (name );
7- }
5+ public Goat (String name ) {
6+ super (name );
7+ }
88
9- @ Override
10- protected String getSound () {
11- return "bleat" ;
12- }
9+ @ Override
10+ protected String getSound () {
11+ return "bleat" ;
12+ }
1313
14- @ Override
15- public String getLocomotion () {
16- return "walks" ;
17- }
14+ @ Override
15+ public String getLocomotion () {
16+ return "walks" ;
17+ }
1818
19- @ Override
20- public String eats () {
21- return "grass" ;
22- }
19+ @ Override
20+ public String eats () {
21+ return "grass" ;
22+ }
2323
2424}
Original file line number Diff line number Diff line change 11package com .baeldung .reflection ;
22
33public interface Locomotion {
4- String getLocomotion ();
4+ String getLocomotion ();
55}
Original file line number Diff line number Diff line change 11package com .baeldung .reflection ;
22
33public class Person {
4- private String name ;
5- private int age ;
4+ private String name ;
5+ private int age ;
66}
You can’t perform that action at this time.
0 commit comments