大分類 Java Kotlin
クラス - class Sample01 { } class Sample01 { }
コンストラク 引数なし public Sample01() { } init { }
コンストラク 引数あり public Sample(String str) { } init(str : String) { }
コンストラク 引数あり
※パターン2
- class Sample01(str : String) { }
メソッド 引数なし、戻り値なし public void test() { } public fun test() { }
メソッド 引数なし、戻り値なし
※パターン2
- fun test() { }
メソッド 引数あり、戻り値あり public String test(String str) { return str; } fun test(str : String) : String { return str }
インターフェース 宣言 public interface Sample() { } interface Sample() { }
インターフェース 実装 public class Sample01 implements Sample { } class Sample01 : Sample { }
継承 - public class Sample01 extends Sample { } class Sample01 : Sample { }
コンソール出力 改行あり System.out.println(""); println("")
コンソール出力 改行なし System.out.print(""); print("")
変数宣言 String(null) String str = null; str : String? = null