Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

inheritance setter and getter in java

public class C1 {
    protected int x = 1;

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public static void main(String[] args){
        System.out.println(new C1().getX());
        System.out.println(new C2().getX());
        System.out.println(new C3().getX());
        System.out.println(new C4().getX());
    }

}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #inheritance #setter #getter #java
ADD COMMENT
Topic
Name
3+6 =