Test Test test 012 multiple class Test int
- Slides: 39
クラスTestの詳細 サンプルプログラム Test test 01=2; multiple(); class Test{ int test 01=2; public void multiple(int test 03){ System. out. println(test 01 * test 03); クラスTestの } インスタンスdtを生成 } dt test 01=2; public class Sample 03 a{ multiple(); public static void main(String[] args){ Test dt = new Test(); メソッドを、引数 100 dt. multiple(100); を渡して実行 dt. test 01=5; dt. multiple(100); multiple(); インスタンスdtの変数 } test 01に代入 }
static 12
直感的な図 概念とか設計図の世界 Test int contents; 実物(オブジェクト)の世界 Data 1 contents = 10; static int st_cont; • push. Contents(); • static cont(); • cont(); Data 2 contents = 20; Test. st_cont=10; st_cont; • • push. Contents(); • cont(); Test. cont(); 15
直感的な図 概念とか設計図の世界 Test int contents; 実物(オブジェクト)の世界 Data 1 contents = 10; static int st_cont; • push. Contents(); • static cont(); • cont(); 同じものを利用。 Data 2 contents = 20; Test. st_cont=10; st_cont; • • push. Contents(); • cont(); Test. cont(); 16
直感的な図 概念とか設計図の世界 Test int contents; 実物(オブジェクト)の世界 Data 1 contents = 10; static int st_cont; • push. Contents(); • static cont(); Test. st_cont=15とすれば、 Data 1. st_cont も15に。 • cont(); Data 2 contents = 20; Test. st_cont=15; st_cont; • • push. Contents(); • cont(); Test. cont(); 17
直感的な図 概念とか設計図の世界 Test ここに値を代入! Data 1. st_count=20 実物(オブジェクト)の世界 Data 1 contents = 10; int contents; static int st_cont; • push. Contents(); • static cont(); • cont(); Data 2 contents = 20; Test. st_cont=20; st_cont; • • Test. cont(); push. Contents(); ここに代入と同じ結果に • cont(); 18
クラスの書き方の例 class Test{ static int st_data; int data; static と書くだけです public void test_func 01(){ System. out. println(data); } public static void test_func 02(){ System. out. println(st_data); } } public class Sample 04 a{ public static void main(String[] args){ Test. st_data=10; Test. test_func 02(); インスタンスを生成しなくて } も使える } 19
サブクラスの書き方例 class Test 01{ int data 01; void test_func 01(){中略} スーパークラス } class Test 02 extends Test 01{ int data 02; } Test 02 サブクラス 拡張された内容 Test 01 int data 01; int data 02; • test_func 01(); 23
生成されたインスタンス class Test 01{ int data 01; void test_func 01(){中略} } dt 02. test_func 01()のように、 普通にアクセス class Test 02 extends Test 01{ int data 02; dt 02. data 01のように、 } 普通にアクセス public class Sample 04 d{ public static void main(String[] args){ Test 02 dt 02 = new Test 02(); 以下略 dt 02 普通に生成 data 01; data 02; • test_func 01(); 24
アブストラクトクラスの例 abstract class Test 01{ void test 01(){ System. out. println("Test 01"); } } class Test 02 extends Test 01{ void test 02(){ System. out. println("Test 02"); } } アブストラクトクラス Test 01をスーパークラス とするサブクラスTest 02 public class Sample 06 a{ public static void main(String[] args){ インスタンスを生成。 Test 02 dt 01 = new Test 02(); } Test 01 dt 01 = new Test 01(); はできない。 } 29
アブストラクトメソッドの例 abstract class Test 01{ void test 01(){ System. out. println("Test 01"); } abstract void test 02(); アブストラクト } メソッド class Test 02 extends Test 01{ void test 02(){ System. out. println("Test 02"); } } public class Sample 06 b{ public static void main(String[] args){ Test 02 dt 01 = new Test 02(); } } アブストラクト クラス Test 01を スーパークラス とする サブクラスTest 02 必ずオーバーライド 31
インターフェースの例 interface Inter. Test 01{ double root_2 = 1. 41421356; void test 01(double ddt); } class Test 02 implements Inter. Test 01{ public void test 01(double ddt){ System. out. println(ddt*root_2); } } public class Sample 07 a{ public static void main(String[] args){ Test 02 dt 01 = new Test 02(); dt 01. test 01(100. 0); } } インターフェースを 実装したクラス インスタンスを生成。 メソッドを実行。 39
- Sum0
- Interface calculator public int add class test
- Int max(int x int y)
- Public void drawsquare(int x, int y, int len)
- Public int divide(int a int b)
- Interface myinterface int foo(int x)
- Int main(int argc, char** argv)
- #include stdio.h int main() int i = 5
- Int factorial(int n)
- Const int vs int arduino
- Int main() int num=4
- Voidswap
- Int f (int n)
- Max int
- Int main int argc char argv
- Public class welcome public static int test
- Class math static int x
- Public class test subject extends test class
- Instalacja rozlewcza irs-2
- Circular 012 pamec excel
- Norme nfp01-012
- Auc rule 012
- Nie cgcre 009
- Ioit-012
- Nom-012-scfi-1994
- Baseline
- Disadvantages of mimd
- Class bucket int capacity bucket()
- Class person string name
- Inheritance example
- Today class or today's class
- Putting a package together
- Introduction to ooad
- Lower boundary of modal class
- Class i vs class ii mhc
- Abstract concrete class relationship
- Class size of class interval
- Stimuli vs stimulus
- Stimulus class vs response class
- 7 rights of medication administration in order