TDD study # 2 (July 13th, 2020)

New knowledge

assertTrue(boolean) Determine if the argument is true. Object.equals

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;
    attend(){}
    test(){}
}

When inherited,

public class Student{
    String name;
    int id;
    attend(){}
}
public class School extends Student{
    test(){}
}

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

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

Access modifier

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

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

private Only accessible from inside the class.

reflection

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

Recommended Posts

TDD study # 2 (July 13th, 2020)
TDD study # 5 (July 18th, 2020)
TDD study # 4 (July 16th, 2020)
TDD study # 3 (July 15th, 2020)
TDD study # 1 environment construction & first test-driven development (July 6th, 2020)
5th
6th
6th
9th
7th
11th
9th
7th
11th
10th
10th