Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

using super in Java

class Shape {
	public void draw() {
		System.out.println("Shape draw.");
	}
}
class Circle extends Shape {
	@Override
	public void draw() {
		System.out.println("Circle draw.");
		super.draw(); // Access parent's version of draw
	}
}
public class Main {
	public static void main(String[] args) {
		Circle c = new Circle();
		// The below prints: 
		// Circle draw.
		// Shape draw.
		c.draw();
	}	
}
 
PREVIOUS NEXT
Tagged: #super #Java
ADD COMMENT
Topic
Name
5+7 =