[Java] TDD Barely #2 (July 13th, 2020)

less than 1 minute read

New knowledge


Determines whether the argument is true.


public boolean equals(Object object){
    return true;

Reference article https://engineer-club.jp/java-equals

type cast

Add (type name) immediately before the target variable.

long l = 1026;
int i = (int) l;

Reference article https://java-code.jp/66

Class inheritance

Class without inheritance

public class School{
    String name;
    int id;

When inherited,

public class Student{
    String name;
    int id;
public class School extends Student{

The original class (student) is called the parent class, the superclass, and the inherited class (school) is called the subclass. ·override → Overwrite the method of the superclass with the subclass.

Reference article https://techacademy.jp/magazine/9246

Access modifier

public Can be accessed from anywhere. Only one in one file. The file name and class name must be the same.

protected It can be accessed from inside a subclass that inherits the class.

private Only accessible from inside the class.


Get an instance of class information with getClass().instance variable. (Unknown)