Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Java Access superclass attribute

class Animal {
  protected String type="animal";
}

class Dog extends Animal {
  public String type="mammal";

  public void printType() {
    System.out.println("I am a " + type);
    System.out.println("I am an " + super.type);
  }
}

class Main {
  public static void main(String[] args) {
    Dog dog1 = new Dog();
    dog1.printType();
  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: precision java 
Java :: java add constructor to enum 
Java :: tostring java 
Java :: java list change element position 
Java :: java insertion sort 
Java :: Java Remove HashMap Elements 
Java :: Syntax of Creating Java Map Objects 
Java :: java final modifier on method 
Java :: login.html 
Java :: data structure java 
Java :: list remove duplicates java 
Java :: finalize method 
Java :: create a string in java 
Java :: format specifier in java 
Java :: how to set default focus on edittext in android 
Java :: one key with multiple values map java 
Java :: java println format 
Java :: extends class in java 
Java :: properties object using a file 
Java :: calling a void method java 
Java :: java stream Return sums of elements grouped by a remainder of division by the give divisor 
Java :: Java public no-arg constructor 
Java :: Algorithms - sum 
Java :: calculate mcd in javsa 
Java :: how to make a messages config minecraft plugin 
Java :: how to accept only numbers and whitespace in java 
Java :: remove character stringbuffer 
Java :: java compareto jdei stackoverflow 
Java :: java main setup 
Java :: setlist arraylist java swing example 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =