LoginSignup
0
0

More than 3 years have passed since last update.

TDD勉強#2(July 13th, 2020)

Posted at

新しい知識

assertTrue(boolean)

引数がtrueかどうか判別する.

Object.equals

public boolean equals(Object object){
    return true;
}

参考記事
https://engineer-club.jp/java-equals

型キャスト

対象の変数の直前に(型名)を付与する.

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

参考記事
https://java-code.jp/66

クラスの継承

継承なしのクラス

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

継承すると,

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

もとのクラス(student)を親クラス,スーパークラス,継承したクラス(school)をサブクラスという.
・オーバーライド
→スーパークラスのメソッドをサブクラスで上書きすること.

参考記事
https://techacademy.jp/magazine/9246

アクセス修飾子

public
どこからでもアクセス可能.一つのファイルに一つだけ.ファイル名とクラス名は同じである必要がある.

protected
そのクラスを継承したサブクラス内部からアクセス可能.

private
クラス内部からのみアクセス可能.

リフレクション

getClass().インスタンス変数でクラス情報のインスタンスを取得する.(意味不明)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0