Java learning memo (inheritance)

I'm studying Java Silver, so I'll upload it as my memorandum. Since it is a rough memo, details are not described.

By inheriting the class, it is possible to inherit the parts that are common to the previously created functions. Add "extends" after the class name of the subclass to describe the class name of the inheritance source (superclass).

1: Display as name.

public class _extends {
    protected String name;
	protected int num;

	protected void method(){
    	System.out.println(num + ":" + name);
	}
}

public class _subextends extends _extends{
	public void method2(String name,int num) {
		super.name = name;
		super.num = num;
		method();
	}
}

public class Test {
	public static void main(String[] str){
		_subextends e = new _subextends();

e.method2 ("name", 1); } }

Recommended Posts

Java learning memo (inheritance)
Java learning memo (method)
Java learning memo (basic)
Java learning memo (interface)
[Java] Implicit inheritance memo
Java learning (0)
JAVA learning history interface inheritance
Java learning memo (data type)
[Java] Inheritance
Java inheritance
Java learning memo (logical operator)
Java inheritance
Java learning memo (abstract class)
java (inheritance)
Java learning memo (creating an array)
java anything memo
[Java] Class inheritance
Java Silver memo
For JAVA learning (2018-03-16-01)
Java learning day 5
java, maven memo
Ruby Learning # 33 Inheritance
java anything memo 2
About java inheritance
Java specification memo
java learning day 2
Java pattern memo
java learning day 1
(Learning memo) Java Level 2 measures: Question range
[Java] Overload / Override / Inheritance
Java Basic Learning Content 6 (Inheritance / Abstract Class / Interface)
Java development environment memo
Java learning 2 (learning calculation method)
java learning (conditional expression)
java basic knowledge memo
Java Kuche Day memo
Summarize Java inheritance (Java Silver 8)
Java Learning (1)-Hello World
[Java ~ Method ~] Study memo (5)
java se 8 programmer Ⅰ memo
Java paid private memo
Learning memo 01 (forward / redirect)
JAVA learning history interface
About inheritance (Java Silver)
[Java ~ Array ~] Study memo 4
java lambda expression memo
(Memo) Java for statement
Java lambda expression [memo]
java competitive programming memo
[Memo] Java Linked List
Learning memo when learning Java for the first time (personal learning memo)
Learning Java framework # 1 (Mac version)
Java (WebSphere Application Server) memo [1]
Advanced inheritance abstract, interface -java
Java basic learning content 7 (exception)
[Java] Variable name naming memo
Java memo (standard class) substring
Java basic learning content 5 (modifier)
Books used for learning Java
4th day of java learning
Java Silver Study Method Memo