From 77d3cbfcc6f84df4ad54aea140c06590dc8491fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B9=B3=E5=B1=B1=E3=80=80=E7=B4=97=E5=B8=86?= <26-s-hirayama-stellatecnica@it-college.co.jp> Date: Wed, 14 Oct 2026 17:26:07 +0900 Subject: [PATCH] =?UTF-8?q?1=E6=97=A5=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ObjectSample_20261014_hirayama.java | 24 ++++++++++++++++++++++++ Student_20261014_hirayama.java | 13 +++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 ObjectSample_20261014_hirayama.java create mode 100644 Student_20261014_hirayama.java diff --git a/ObjectSample_20261014_hirayama.java b/ObjectSample_20261014_hirayama.java new file mode 100644 index 0000000..a1bfd9b --- /dev/null +++ b/ObjectSample_20261014_hirayama.java @@ -0,0 +1,24 @@ + +public class ObjectSample { + + public static void main(String[] args) { + // TODO 自動生成されたメソッド・スタブ + //原本のコピー(インスタンス生成) + Student student1 = new Student(); + Student student2 = new Student(); + + //name、ageへの代入 + student1.name = "田中"; + student1.age = 30; + + student2.name = "山本"; + student2.age = 25; + + //introduceメソッドの呼び出し + student1.intoroduce(); + + student2.intoroduce(); + } +} + + \ No newline at end of file diff --git a/Student_20261014_hirayama.java b/Student_20261014_hirayama.java new file mode 100644 index 0000000..bd0981c --- /dev/null +++ b/Student_20261014_hirayama.java @@ -0,0 +1,13 @@ + +public class Student { + //フィールドの宣言 + String name; + int age; + + //メソッドの定義 + public void intoroduce() { + System.out.println("私の名前は" + this.name); + System.out.println("年齢は" + this.age); + } + +}