明解Java入門編

Size: px
Start display at page:

Download "明解Java入門編"

Transcription

1

2 38812 TimeAccount List 12-1 Account List 12-1 // Chap12/TimeAccount.java class TimeAccount { private String name; private String no; private long balance; private long timebalance; // // // // // // TimeAccount(String n, String num, long z, long timebalance) { name = n; // no = num; // balance = z; // this.timebalance = timebalance; // // // String getname() { return name; // // String getno() { return no;

3 389 // // long getbalance() { return balance; // // long gettimebalance() { return timebalance; //--- k ---// void deposit(long k) { balance += k; //--- k ---// void withdraw(long k) { balance -= k; // // void cancel(long k) { balance += timebalance; timebalance = 0; 12-1 Account Account a b 1, -1, 0 TimeAccount // static int compbalance(account a, Account b) { if (a.getbalance() > b.getbalance()) return 1; else if (a.getbalance() < b.getbalance()) return -1; return 0; // a // b // ab TimeAccount Account TimeAccount

4 39012 class Base { int a; int b; int geta() { /**/ void seta(int a) { /**/ int getb() { /**/ void setb(int b) { /**/ class Derived extends Base { int c; int getc() { /**/ void setc(int c) { /**/ derive inheritance Base Derived Fig.12-1 extends Derived Derived Base Fig.12-1

5 391 Base Derived Derived Base Base Derived Base a, b a, b Derived c Base Fig Fig.12-2

6 39212 List 12-2 // // class Point2D { int x; // int y; // Point2D(int x, int y) { this.x = x; this.y = y; void setx(int x) { this.x = x; // void sety(int y) { this.y = y; // int getx() { return x; // int gety() { return y; // Chap12/PointTester.java List 12-2 // class Point3D extends Point2D { int z; // Point3D(int x, int y, int z) { super(x, y); this.z = z; void setz(int z) { this.z = z; int getz() { return z; // // public class PointTester { public static void main(string[] args) { Point2D a = new Point2D(10, 15); Point3D b = new Point3D(20, 30, 40); a = (10, 15) b = (20, 30, 40) System.out.printf("a = (%d, %d)\n", a.getx(), a.gety()); System.out.printf("b = (%d, %d, %d)\n", b.getx(), b.gety(), b.getz());

7 393 Point2D Point3D Fig.12-1 Base Derived Point2D x, y x, y x y Point3D Point2D z 12-1 super(x, y); super(...) super(x, y) x, y x y ゆだ Point3D z super(...) super(...) super(...) this(...) super this main a b getx gety b Point2D getx gety Point3D

8 39412 Point3D super(...) // Point3D(int x, int y, int z) { this.x = x; this.y = y; this.z = z; super(...) super() // Point3D(int x, int y, int z) { super(); this.x = x; this.y = y; this.z = z; Point2D super(...) super(); X から X() { X() { super(); // X() { super();

9 395 List 12-3 List 12-3 Chap12/DefaultConstructor.java // // class A { private int a; x.geta() = 50 A() { a = 50; int geta() { return a; // class B extends A { // public class DefaultConstructor { public static void main(string[] args) { B x = new B(); System.out.println("x.getA() = " + x.geta()); A int a a 50 geta B A B() { super(); // 12-1 B super() A B B super() A(int x) { a = x; // B A a 50

10 39612 // class Base { protected int x; // void print() { System.out.println("Base.x = " + x); // class Derived extends Base { int x; // super Derived(int x1, int x2) { super.x = x1; this.x = x2; // void print() { super.print(); System.out.println("Derived.x = " + x); public class SuperTester { super. List 12-4 List 12-4 // Chap12/SuperTester.java Base() { this.x = 0; Base(int x) { this.x = x; public static void main(string[] args) { Base a = new Base(10); System.out.println("-- a --"); a.print(); Derived b = new Derived(20, 30); System.out.println("-- b --"); b.print(); -- a -- Base.x = b -- Base.x = 20 Derived.x = 30 x protected x print Base Derived Derived Base x private protected

11 12-1Fig x Base x Fig.12-3 Base x1 x2 x super.x Base x this.x Derived x super. this. x this.x print Base super.print() Base print Derived print Base x Derived x override

12 39812 Fig.12-4 Fig.12-4 A B B C D B A 4 C D B 4 A class A { //... class C extends B { //... class B extends A { //... class D extends B { //... super class sub class direct super class direct sub class Table 12-1 Table 12-1

13 399 super super super() Fig class Q extends A, B { //... Fig.12-5 class Derived extends Base { /**/ extends Base Base Base

14 40012 class A { //... class B extends A { //... class C extends B { //... class D extends B { //... Fig.12-6 Fig.12-6 Fig.12-4 Object A extends Object Object java.lang Column 12-6 extends Object extends Account Car Day Object Object Ojbect A Object B Object Account Car Day Object Object

15 401 List 12-5 TimeAccount List 12-5 // class TimeAccount extends Account { private long timebalance; // account2/timeaccount.java // TimeAccount(String name, String no, long balance, long timebalance) { super(name, no, balance); // Account this.timebalance = timebalance; // // long gettimebalance() { return timebalance; // void cancel(long k) { deposit(timebalance); timebalance = 0; 12-1 Account incremental programming List 12-2

16 40212 TimeAccount Account Account Account TimeAccount Account 4 Account TimeAccount List 12-6 List 12-6 // account2/timeaccounttester1.java x200 class TimeAccountTester1 { y200 y500 public static void main(string[] args) { Account adachi = new Account("", "123456", 1000); TimeAccount nakata = new TimeAccount("", "654321", 200, 500); Account x; x = adachi; x = nakata; System.out.println("x" + x.getbalance()); TimeAccount y; // // y = adachi; // y = nakata; // System.out.println("y" + y.getbalance()); System.out.println("y" + y.gettimebalance()); // // // main adachi Account nakata TimeAccount x Account y TimeAccount x y adachi nakata Fig.12-7 Account x adachi TimeAccount y nakata

17 403 Fig nakata TimeAccount Account x TimeAccount Account Account TimeAccount gettimebalance cancel TimeAccount Account Account x Account TimeAccount TimeAccount y Account adachi y adachi y gettimebalance y.gettimebalance() y adachi Account

18 40412 List 12-7 compbalance a b 1, -1, 0 List 12-7 // account2/timeaccounttester2.java class TimeAccountTester2 { // static int compbalance(account a, Account b) { if (a.getbalance() > b.getbalance()) // a return 1; else if (a.getbalance() < b.getbalance()) // b return -1; return 0; // ab a b Account main Account TimeAccount Account Account TimeAccount public static void main(string[] args) { Account adachi = new Account("", "123456", 1000); TimeAccount nakata = new TimeAccount("", "654321", 200, 500); switch (compbalance(adachi, nakata)) { case 0 : System.out.println(""); break; case 1 : System.out.println(""); break; case -1 : System.out.println(""); break; a b TimeAccount main TimeAccount Account Car

19 405 Object Object List 12C-1 List 12C-1 Chap12/ToString.java // tostring class X { public String tostring() { return "Class X"; class Y extends X { public String tostring() { return "Class Y"; public class ToString { //--- tostring ---// 12-1static void print(object obj) { System.out.println(obj); public static void main(string[] args) { X x = new X(); Y y = new Y(); int[] c = new int[5]; print(x); print(y); print(c); Class X Class Y [I@ca0b6 X Object Y X print obj Object obj obj tostring main X x Y y int c print x X tostring "Class X" y Y tostring "Class Y" Object Object ObjecttoString final int length List 6-15 tostring

20 40612 name mastername Pet getname name ++++ **** ++++ **** Fig.12-8 getmastername mastername introduce Fig.12-8 List 12-8 Pet RobotPet Pet RobotPet super(...) Pet introduce Pet work 0, 1, 2 RobotPet Pet getname, getmastername introduce work

21 407 List 12-8 // class Pet { private String name; private String mastername; // // pet/pet.java // public Pet(String name, String mastername) { this.name = name; // this.mastername = mastername; // // public String getname() { return name; // public String getmastername() { return mastername; // public void introduce() { System.out.println("" + name + ""); System.out.println("" + mastername + ""); class RobotPet extends Pet { // public RobotPet(String name, String mastername) { super(name, mastername); // // public void introduce() { System.out.println("" + getname() + ""); System.out.println("" + getmastername() + ""); 12-2 // public void work(int sw) { switch (sw) { case 0: System.out.println(""); break; case 1: System.out.println(""); break; case 2: System.out.println(""); break; introduce override RobotPet introduce Pet introduce

22 40812 List 12-9 List 12-9 // class PetTester1 { public static void main(string[] args) { Pet kurt = new Pet("Kurt", ""); kurt.introduce(); System.out.println(); RobotPet r2d2 = new RobotPet("R2D2", ""); r2d2.introduce(); System.out.println(); Pet p = r2d2; p.introduce(); Pet kurt Pet introduce RobotPet r2d2 RobotPet introduce pet/pettester1.java Kurt R2D2 R2D2 Pet p RobotPet p.introduce() p Pet Pet introduce R2D2 RobotPet RobotPet introduce R2D2

23 409 if (sw == 1) p = kurt; else p = r2d2; p.introduce(); // ppet // probotpet // ppetrobotpet sw int p Pet kurt RobotPet r2d2 p kurt r2d2 Pet introduce 12-2 sw 1 Pet introduce RobotPet introduce

24 41012 polymorphism Fig static bindingearly binding dynamic bindinglate binding 4 4 Kurt R2D2 Fig.12-9

25 411 List List // class PetTester2 { // p static void intro(pet p) { p.introduce(); public static void main(string[] args) { Pet[] a = { new Pet("Kurt", ""), new RobotPet("R2D2", ""), new Pet("", ""), ; for (Pet p : a) { intro(p); System.out.println(); pet/pettester2.java Kurt R2D2 // p 12-2 intro p Pet p introduce p Pet Pet RobotPet main Pet RobotPet intro Pet a[0] a[2] Pet introduce RobotPet a[1] RobotPet introduce

26 41212 Pet RobotPet Pet p = new RobotPet("R2D2", ""); RobotPet Pet widening reference conversionup castfig Pet p = (Pet)new RobotPet("R2D2", ""); RobotPet r1 = new Pet("Kurt", ""); // RobotPet r2 = (RobotPet)new Pet("Kurt", ""); // narrowing reference conversion down cast r2 r2.work(0); // Fig.12-10

27 413 List List // instanceof class PetInstanceOf { public static void main(string[] args) { Pet[] a = { new Pet("Kurt", ""), new RobotPet("R2D2", ""), new Pet("", ""), ; pet/petinstanceof.java a[0] Kurt a[1] a[2] for (int i = 0; i < a.length; i++) { System.out.println("a[" + i + "] "); if (a[i] instanceof RobotPet) // a[i] ((RobotPet)a[i]).work(0); // else // a[i].introduce(); // 12-2 instanceof Table 12-2 instnaceof a[i] RobotPet a[i] RobotPet Table 12-2 x instanceof t x t true false if a[i] Pet RobotPet a[i] instanceof Pet true if (a[i] instanceof Pet) // PetPettrue a[i].introduce(); // a[i]petrobotpet else ((RobotPet)a[i]).work(0); //

28 41412 RobotPet introduce introduction 4 class RobotPet { // public void introduction() { // System.out.println("" + getname() + ""); System.out.println("" + getmastername() + ""); // RobotPet introduction introduce introduction List 12-9 p.introduce() RobotPet class RobotPet { public void introduction() { // System.out.println("" + getname() + ""); System.out.println("" + getmastername() + ""); //

29 415 Pet introduction introduction class RobotPet { public void introduce() { // System.out.println("" + getname() + ""); System.out.println("" + getmastername() + ""); // 12-2@Override 4 æ` n téi n e e a, b compbalance static int compbalance(timeaccount a, TimeAccount b) a 1 0b -1 a @Deplicate

30 41612 member private private private

31 417 final final final String final String class DeluxeString extends String { // //... final 12-3 final final final void f() { /**/ final final final final final final

32 41812 Fig public m1 private m4 public class A { public void m1() { // public protected void m2() { // protected void m3() { // private void m4() { // private Fig Table 12-3 Table 12-3 A m1 public public m2 public protected public public protected

33 419 A m4 tostring public Object tostring public Column 12-6toString public String tostring() public 12-3class A { static void f() { /* */ class B extends A { void f() { /* */ // public final Table 12C-1 Table 12C-1 publicprotectedprivateabstractstaticfinal strictfp publicprotectedprivatestaticfinaltransient volatile publicprotectedprivateabstractstaticfinal synchronizednativestrictfp publicprotectedprivateabstractstaticstrictfp

34 42012 Object List 12C-2 List 12C-2 // Object package java.lang; public class Object { static { registernatives(); public final native Class<?> getclass(); public native int hashcode(); public boolean equals(object obj) { return (this == obj); protected native Object clone() throws CloneNotSupportedException; API/Object.java public String tostring() { return getclass().getname() + "@" + Integer.toHexString(hashCode()); public final native void notify(); public final native void notifyall(); public final native void wait(long timeout) throws InterruptedException; public final void wait(long timeout, int nanos) throws InterruptedException { if (timeout < 0) { throw new IllegalArgumentException("timeout value is negative"); if (nanos < 0 nanos > ) { throw new IllegalArgumentException( "nanosecond timeout value out of range"); if (nanos >= (nanos!= 0 && timeout == 0)) { timeout++; wait(timeout); public final void wait() throws InterruptedException { wait(0); protected void finalize() throws Throwable { java.lang Object java.lang native getclass native

35 hashcode 421 int hashcode Day hashcode public int hashcode() { return (year * 372) + (month * 31) + date; year, month, date equals equals true false a.equals(b) true a b a.hashcode() b.hashcode() false a b equals hashcode Day equals equalto hashcode Object equals public boolean equals(object obj) { if (this == obj) // return true; if (obj instanceof Day) { // objday Day d = (Day)obj; return (year == d.year && month == d.month && date == d.date)? true : false; return false; hashcode equalto equals day tostring Object tostring "@"

36 42212 Object Object super(...) super() super() super. B A B A

37 // // public class SpecialMember extends Member { private String privilege; // public SpecialMember(String name, int no, int age, String privilege) { super(name, no, age); this.privilege = public void print() { super.print(); System.out.println("" + privilege); // // public class Member { private String name; private int no; private int age; // // // public Member(String name, int no, int age) { this.name = name; this.no = no; this.age = age; public String getname() { return name; public void print() { System.out.println("No." + no + "" + name + "" + age + ""); // // public class MemberTester { public static void main(string[] args) { Member[] m = { new Member("", 101, 27), new SpecialMember("", 102, 31, ""), new SpecialMember("", 103, 52, ""), ; for (Member k : m) { k.print(); System.out.println(); No No No.10352

新・明解Java入門

新・明解Java入門 537,... 224,... 224,... 32, 35,... 188, 216, 312 -... 38 -... 38 --... 102 --... 103 -=... 111 -classpath... 379 '... 106, 474!... 57, 97!=... 56 "... 14, 476 %... 38 %=... 111 &... 240, 247 &&... 66,

More information

Microsoft PowerPoint ppt

Microsoft PowerPoint ppt 独習 Java ( 第 3 版 ) 6.7 変数の修飾子 6.8 コンストラクタの修飾子 6.9 メソッドの修飾子 6.10 Object クラスと Class クラス 6.7 変数の修飾子 (1/3) 変数宣言の直前に指定できる修飾子 全部で 7 種類ある キーワード final private protected public static transient volatile 意味定数として使える変数同じクラスのコードからしかアクセスできない変数サブクラスまたは同じパッケージ内のコードからしかアクセスできない変数他のクラスからアクセスできる変数インスタンス変数ではない変数クラスの永続的な状態の一部ではない変数不意に値が変更されることがある変数

More information

ALG ppt

ALG ppt 2012 6 21 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 1 l l O(1) l l l 2 (123 ) l l l l () l H(k) = k mod n (k:, n: ) l l 3 4 public class MyHashtable

More information

untitled

untitled 2011 6 20 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2011/index.html tech.ac.jp/k1sakai/lecture/alg/2011/index.html html 1 O(1) O(1) 2 (123) () H(k) = k mod n

More information

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF pref : 2004/6/5 (11:8) pref : 2004/6/5 (11:8) pref : 2004/6/5 (11:8) 3 5 14 18 21 23 23 24 28 29 29 31 32 34 35 35 36 38 40 44 44 45 46 49 49 50 pref : 2004/6/5 (11:8) 50 51 52 54 55 56 57 58 59 60 61

More information

解きながら学ぶJava入門編

解きながら学ぶJava入門編 44 // class Negative { System.out.print(""); int n = stdin.nextint(); if (n < 0) System.out.println(""); -10 Ÿ 35 Ÿ 0 n if statement if ( ) if i f ( ) if n < 0 < true false true false boolean literalboolean

More information

Java演習(4) -- 変数と型 --

Java演習(4)   -- 変数と型 -- 50 20 20 5 (20, 20) O 50 100 150 200 250 300 350 x (reserved 50 100 y 50 20 20 5 (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; (reserved public class Blocks1 extends

More information

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV tutimura@mist.i.u-tokyo.ac.jp kaneko@ipl.t.u-tokyo.ac.jp http://www.misojiro.t.u-tokyo.ac.jp/ tutimura/sem3/ 2002 12 11 p.1/33 10/16 1. 10/23 2. 10/30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20

More information

K227 Java 2

K227 Java 2 1 K227 Java 2 3 4 5 6 Java 7 class Sample1 { public static void main (String args[]) { System.out.println( Java! ); } } 8 > javac Sample1.java 9 10 > java Sample1 Java 11 12 13 http://java.sun.com/j2se/1.5.0/ja/download.html

More information

226

226 226 227 Main ClientThread Request Channel WorkerThread Channel startworkers takerequest requestqueue threadpool WorkerThread channel run Request tostring execute name number ClientThread channel random

More information

Java学習教材

Java学習教材 Java 2016/4/17 Java 1 Java1 : 280 : (2010/1/29) ISBN-10: 4798120987 ISBN-13: 978-4798120980 2010/1/29 1 Java 1 Java Java Java class FirstExample { public static void main(string[] args) { System.out.println("

More information

Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN Exam's Question and Answers 1 from Ac

Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN Exam's Question and Answers 1 from Ac Actual4Test http://www.actual4test.com Actual4test - actual test exam dumps-pass for IT exams Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN

More information

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println(Hello World); (Basic Theory of Information Processing) Java (eclipse ) Hello World! eclipse Java 1 3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello

More information

8 if switch for while do while 2

8 if switch for while do while 2 (Basic Theory of Information Processing) ( ) if for while break continue 1 8 if switch for while do while 2 8.1 if (p.52) 8.1.1 if 1 if ( ) 2; 3 1 true 2 3 false 2 3 3 8.1.2 if-else (p.54) if ( ) 1; else

More information

(Eclipse\202\305\212w\202\324Java2\215\374.pdf)

(Eclipse\202\305\212w\202\324Java2\215\374.pdf) C H A P T E R 11 11-1 1 Sample9_4 package sample.sample11; public class Sample9_4 { 2 public static void main(string[] args) { int[] points = new int[30]; initializearray(points); double averagepoint =

More information

Javaセキュアコーディングセミナー2013東京第1回 演習の解説

Javaセキュアコーディングセミナー2013東京第1回 演習の解説 Java セキュアコーディングセミナー東京 第 1 回オブジェクトの生成とセキュリティ 演習の解説 2012 年 9 月 9 日 ( 日 ) JPCERT コーディネーションセンター脆弱性解析チーム戸田洋三 1 演習 [1] 2 演習 [1] class Dog { public static void bark() { System.out.print("woof"); class Bulldog

More information

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2;

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2; 5 p.1 5 JPanel (toy example) 5.1 2 extends : Object java.lang.object extends... extends Object Point.java 1 public class Point { // public int x; public int y; Point x y 5.1.1, 5 p.2 5 5.2 Point int Java

More information

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1) int boolean switch case C Calendar java.util.calendar A

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1) int boolean switch case C Calendar java.util.calendar A Java 3 p.1 3 Java Java if for while C 3.1 if Java if C if if ( ) 1 if ( ) 1 else 2 1 1 2 2 1, 2 { Q 3.1.1 1. int n = 2; if (n

More information

た場合クラスを用いて 以下のように書くことが出来る ( 教科書 p.270) プログラム例 2( ソースファイル名 :Chap08/AccountTester.java) // 銀行口座クラスとそれをテストするクラス第 1 版 // 銀行口座クラス class Account String name

た場合クラスを用いて 以下のように書くことが出来る ( 教科書 p.270) プログラム例 2( ソースファイル名 :Chap08/AccountTester.java) // 銀行口座クラスとそれをテストするクラス第 1 版 // 銀行口座クラス class Account String name クラス ( 教科書第 8 章 p.267~p.297) 前回は処理をまとめる方法として メソッドについて学習した 今回はメソッドとその処理の対象となるデータをまとめるためのクラスについて学習する このクラスはオブジェクト指向プログラミングを実現するための最も重要で基本的な技術であり メソッドより一回り大きなプログラムの部品を構成する 今回はクラスにおけるデータの扱いとクラスの作成方法 使用方法について説明していく

More information

新・明解Javaで学ぶアルゴリズムとデータ構造

新・明解Javaで学ぶアルゴリズムとデータ構造 第 3 章 探索 Arrays.binarySearch 743 3-1 探索 探索 searching key 配列 探索 Fig.3-1 b c 75 a 6 4 3 2 1 9 8 2 b 64 23 53 65 75 21 3-1 53 c 5 2 1 4 3 7 4 Fig.3-1 a 763 3-2 線形探索 線形探索 linear search sequential search 2

More information

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲 Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲を決定します 次の型が利用でき これらの型は特に基本型とよばれます 基本型 値の種類 値の範囲 boolean

More information

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 条件判断文 3 switch 文 switch 文式が case の値と一致した場合 そこから直後の break; までを処理し どれにも一致しない場合 default; から直後の break; までを処理する 但し 式や値 1

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 条件判断文 3 switch 文 switch 文式が case の値と一致した場合 そこから直後の break; までを処理し どれにも一致しない場合 default; から直後の break; までを処理する 但し 式や値 1 Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 条件判断文 3 switch 文 switch 文式が case の値と一致した場合 そこから直後の までを処理し どれにも一致しない場合 default; から直後の までを処理する 但し 式や値 1 値 2は整数または文字である switch( 式 ) case 値 1: // コロン : です セミコロン ; と間違えないように!!

More information

明解Javaによるアルゴリズムとデータ構造

明解Javaによるアルゴリズムとデータ構造 21 algorithm List 1-1 a, b, c max Scanner Column 1-1 List 1-1 // import java.util.scanner; class Max3 { public static void main(string[] args) { Scanner stdin = new Scanner(System.in); Chap01/Max3.java

More information

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。 解答例 問題 1 変数 a が 3 以上でかつ 7 以下の場合 true と表示し そうでない場合は false と表示するプログラムである public class Prog061004_01 { int a; boolean b; a = Integer.parseInt(buf.readLine()); b = (a >= 3) && (a

More information

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の まで処理しますどれにも一致致しない場合 default: から直後の まで処理します 式の結果 ラベル 定数 整数または文字 (byte, short, int,

More information

明解Javaによるアルゴリズムとデータ構造

明解Javaによるアルゴリズムとデータ構造 74 searching 3 key Fig.3-1 75 2を探索 53を探索 3-1 5 2 1 4 3 7 4 を探索 Fig.3-1 76 3 linear searchsequential search 2 Fig.3-2 0 ❶ ❷ ❸ 配列の要素を先頭から順に走査していく 探索すべき値と等しい要素を発見 Fig.3-2 6 4 3 2 3-2Fig.3-3 77 5 Fig.3-3 0

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅰ 3 回目変数 今日の講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能です 変数は 型 ( データ型ともいいます ) と識別子をもちます 2 型 変数に記憶できる値の種類です型は 値の種類に応じて次の 8 種類があり これを基本型といいます 基本型値の種類値の範囲または例 boolean 真偽値 true または

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅱ 7 回目オーバーライド課題 確認 問題次の各文は正しいか誤っているか答えなさい (1) スーパークラスのメソッドと同じ名前 戻り値 引数の個数と型をもつメソッドをサブクラスで宣言すると これらのメソッドはオーバーライドの関係になる (2) メソッドのオーバーライドとは スーパークラスのメソッドに代わってサブクラスのメソッドが実行される機能のことである (3) スーパークラス型の変数にサブクラスのオブジェクトは代入できない

More information

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1 Java (9) 1 Lesson 7 2008-05-20 Java System.out.println() 1 Java API 1 Java Java 1 GUI 2 Java 3 1.1 5 3 1.0 10.0, 1.0, 0.5 5.0, 3.0, 0.3 4.0, 1.0, 0.6 1 2 4 3, ( 2 3 2 1.2 Java (stream) 4 1 a 5 (End of

More information

PowerPoint Presentation

PowerPoint Presentation UML 2004 7 9 10 ... OOP UML 10 Copyright 2004 Akira HIRASAWA all rights reserved. 2 1. 2. 3. 4. UML 5. Copyright 2004 Akira HIRASAWA all rights reserved. 3 1..... Copyright 2004 Akira HIRASAWA all rights

More information

:30 12:00 I. I V II. III. IV. ( a d) V. VI : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeyliste

:30 12:00 I. I V II. III. IV. ( a d) V. VI : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeyliste 2017 07 28 10:30 12:00 I. I V II. III. IV. ( a d) V. VI. 80 100 60 : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeylistener KE KeyEvent M MouseListener am addmouselistener

More information

IT プロジェクト

IT プロジェクト オブジェクト指向設計による卓球 ゲームの試作 (2) 劉少英 情報科学部コンピュータ科学科 Email:sliu@hosei.ac.jp ホームページ : http://cis.k.hosei.ac.jp/~sliu/ 講義内容 1. 卓球ボールをテーブルの上に移動させる 2. 関連しているクラスにメソッドを加える 3. プログラムの文書化技術 1. 卓球ボールをテーブルの上に 移動させる 8 9

More information

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value = Part2-1-3 Java (*) (*).class Java public static final 1 class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value

More information

I HTML HashMap (i) (ii) :.java import java.net.*; import java.io.*; import java.util.hashmap; public class SimpleStopWatch { public static voi

I HTML HashMap (i) (ii) :.java import java.net.*; import java.io.*; import java.util.hashmap; public class SimpleStopWatch { public static voi II Java 10 2 12 10:30 12:00 I. I III II. III. IV. ( a d) V. : this==null, T == N A ActionListener C class D actionperformed G getsource I implements K KeyListener J JApplet L addmouselistener M MouseListener

More information

http://www.impressjapan.jp/ Copyright 2014 Socius Japan, Inc. All rights reserved. Java SE 7 Java SE 7 OCJ-P Bronze SE 7 Java Java SE 7 Bronze OCJ-P Silver SE 7 Java Java SE 7 Programmer I OCJ-P Gold

More information

10K

10K 1 2 3 4 Object Oriented Object Oriented Programming(OOP) 5 6 OOP#1 OOP#2 Java 7 Java 8 手続き型 v.s. OOP #1 OOPのメリット#3 追加 変更がラク 出典 立山秀利 Javaのオブジェクト指向がゼッタイにわかる本 秀和システム 出典 立山秀利 Javaのオブジェクト指向がゼッタイにわかる本 秀和システム

More information

Thread

Thread 14 2013 7 16 14.1....................................... 14 1 14.2 Thread................................... 14 1 14.3............................. 14 5 14.4....................................... 14 10

More information

目的 泡立ち法を例に Comparableインターフェイスの実装 抽象クラスの利用 型パラメタの利用 比較 入替 の回数を計測

目的 泡立ち法を例に Comparableインターフェイスの実装 抽象クラスの利用 型パラメタの利用 比較 入替 の回数を計測 泡立ち法とその実装 計算機アルゴリズム特論 :2017 年度只木進一 目的 泡立ち法を例に Comparableインターフェイスの実装 抽象クラスの利用 型パラメタの利用 比較 入替 の回数を計測 Comparable インターフェイ ス クラスインスタンスが比較可能であることを示す Int compareto() メソッドを実装 Integer Double String などには実装済み public

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅰ 3 回目変数 今日の講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能です 変数は 型 ( データ型ともいいます ) と識別子をもちます 2 型 変数に記憶できる値の種類です型は 値の種類に応じて次の 8 種類があり これを基本型といいます 基本型値の種類値の範囲または例 boolean 真偽値 true または

More information

extends (*) (*) extend extends 2

extends (*) (*) extend extends 2 2007-2-1-4 1 1.1 1 extends (*) (*) extend extends 2 class Person { private String name; String name() {return name; Person(String name) { this.name=name; class Worker extends Person { private int salary;

More information

アルゴリズムとデータ構造1

アルゴリズムとデータ構造1 1 200972 (sakai.keiichi@kochi sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi ://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2009/index.html 29 20 32 14 24 30 48 7 19 21 31 Object public class

More information

Java 基礎問題ドリル ~ メソッドを理解する ~ 次のプログラムコードに 各設問の条件にあうメソッドを追加しなさい その後 そのメソッドが正しく動作することを検証するためのプログラムコードを main メソッドの中に追加しなさい public class Practice { // ここに各設問

Java 基礎問題ドリル ~ メソッドを理解する ~ 次のプログラムコードに 各設問の条件にあうメソッドを追加しなさい その後 そのメソッドが正しく動作することを検証するためのプログラムコードを main メソッドの中に追加しなさい public class Practice { // ここに各設問 Java 基礎問題ドリル ~ メソッドを理解する ~ 次のプログラムコードに 各設問の条件にあうメソッドを追加しなさい その後 そのメソッドが正しく動作することを検証するためのプログラムコードを main メソッドの中に追加しなさい public class Practice { // ここに各設問のメソッドを追加する public static void main(string[] args) {

More information

Java (7) Lesson = (1) 1 m 3 /s m 2 5 m 2 4 m 2 1 m 3 m 1 m 0.5 m 3 /ms 0.3 m 3 /ms 0.6 m 3 /ms 1 1 3

Java (7) Lesson = (1) 1 m 3 /s m 2 5 m 2 4 m 2 1 m 3 m 1 m 0.5 m 3 /ms 0.3 m 3 /ms 0.6 m 3 /ms 1 1 3 Java (7) 2008-05-20 1 Lesson 5 1.1 5 3 = (1) 1 m 3 /s 1 2 3 10 m 2 5 m 2 4 m 2 1 m 3 m 1 m 0.5 m 3 /ms 0.3 m 3 /ms 0.6 m 3 /ms 1 1 3 1.2 java 2 1. 2. 3. 4. 3 2 1.3 i =1, 2, 3 V i (t) 1 t h i (t) i F, k

More information

ユニット・テストの概要

ユニット・テストの概要 2004 12 ... 3... 3... 4... 5... 6... 6 JUnit... 6... 7 Apache Cactus... 7 HttpUnit/ServletUnit... 8 utplsql... 8 Clover... 8 Anthill Pro... 9... 10... 10... 10 SQL... 10 Java... 11... 11... 12... 12 setter

More information

Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一

Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一 Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一 2 基本的考え方 リスト ( あるいは配列 )SS の中の ある要素 xx(pivot) を選択 xx より小さい要素からなる部分リスト SS 1 xx より大きい要素からなる部分リスト SS 2 xx は SS 1 または SS 2 に含まれる 長さが 1 になるまで繰り返す pivot xx の選び方として 中央の要素を選択すると効率が良い

More information

I. (i) Java? (A). 2Apples (B). Vitamin-C (C). Peach21 (D). Pine_Apple (ii) Java? (A). Java (B). Java (C). Java (D). JavaScript Java JavaScript Java (i

I. (i) Java? (A). 2Apples (B). Vitamin-C (C). Peach21 (D). Pine_Apple (ii) Java? (A). Java (B). Java (C). Java (D). JavaScript Java JavaScript Java (i 12 7 27 10:30 12:00 I. I VI II. III. IV. ( a d) V. VI. 80 100 60 : this==null, T == N A ActionListener A addactionlistener C class D actionperformed E ActionEvent G getsource I implements J JApplet K KeyListener

More information

1: JX-model XML File Package Import Class Intf Ctor Method SInit Field Param Local ExtdOpt ImplOpt ThrwOpt Members QName Type Stmt Label Expr ident li

1: JX-model XML File Package Import Class Intf Ctor Method SInit Field Param Local ExtdOpt ImplOpt ThrwOpt Members QName Type Stmt Label Expr ident li Sapid JX-model ver. 1.3.13 2003 2 27 1 JX-model Java XML JX-model JX-model Java (Java 2 ver. 1.4) 20 7 JX-model 1 ^ $ Child nodes JX-model / ( ) JX-model @ @id @sort 1.1 File File JX-model XML /Package,

More information

break 文 switch ブロック内の実行中の処理を強制的に終了し ブロックから抜けます switch(i) 強制終了 ソースコード例ソースファイル名 :Sample7_1.java // 入力値の判定 import java.io.*; class Sample7_1 public stati

break 文 switch ブロック内の実行中の処理を強制的に終了し ブロックから抜けます switch(i) 強制終了 ソースコード例ソースファイル名 :Sample7_1.java // 入力値の判定 import java.io.*; class Sample7_1 public stati Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の まで処理しますどれにも一致しない場合 default: から直後の まで処理します 式は byte, short, int, char 型 ( 文字または整数 ) を演算結果としますラベルには整数リテラル

More information

{:from => Java, :to => Ruby } Java Ruby KAKUTANI Shintaro; Eiwa System Management, Inc.; a strong Ruby proponent http://kakutani.com http://www.amazon.co.jp/o/asin/4873113202/kakutani-22 http://www.amazon.co.jp/o/asin/477413256x/kakutani-22

More information

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225 Java Java Java Java Java 4 p35 4-2 * *** ***** *** * Unix p36 4-3 a,b,c,d 100,200,250,500 a*b = 20000 a*b+c = 20250 a*b+c*d = 145000 (a+b)*(c+d) = 225000 a+b*c+d = 50600 b/a+d/c = 4 p38 4-4 (1) mul = 1

More information

untitled

untitled -1- 1. JFace Data Binding JFace Data Binding JFace SWT JFace Data Binding JavaBean JFace Data Binding JavaBean JFace Data Binding 1JFace Data Binding JavaBean JavaBean JavaBean name num JavaBean 2JFace

More information

DVIOUT-exer

DVIOUT-exer プログラム理論と言語 : 期末試験用問題集 Part2 (2009) 演習問題 2-0 オブジェクト指向言語, とりわけ Java に関する用語の設問をもうける. 重要な語句については復習をしておくこと. 1 演習問題 2-1( レジメ記載の問題を具体化した問題 ) 下記は, 整数 (int) を要素とする線形リストのプログラムである. class IntCell { private int value

More information

I java A

I java A I java 065762A 19.6.22 19.6.22 19.6.22 1 1 Level 1 3 1.1 Kouza....................................... 3 1.2 Kouza....................................... 4 1.3..........................................

More information

Microsoft Word - NonGenList.doc

Microsoft Word - NonGenList.doc ジェネリクスとコンパレータを使用しないリストのプログラム例 1. ポインタによる線形リスト LinkedListNG.java: ポインタによる線形リストのクラス LinkedListNG LinkedListTesterNG.java: LinkedListNG を利用するプログラム例 2. カーソルによる線形リスト AryLinkedListNG.java: カーソルによる線形リストのクラス AryLinkedListNG

More information

新・明解Javaで学ぶアルゴリズムとデータ構造

新・明解Javaで学ぶアルゴリズムとデータ構造 第 1 章 基本的 1 n 21 1-1 三値 最大値 algorithm List 1-1 a, b, c max // import java.util.scanner; class Max3 { public static void main(string[] args) { Scanner stdin = new Scanner(System.in); List 1-1 System.out.println("");

More information

Microsoft Word - NonGenTree.doc

Microsoft Word - NonGenTree.doc ジェネリクスとコンパレータを使用しない 2 分探索木のプログラム例 BinTreeNG.java: 2 分探索木のクラス BinTreeNG BinTreeTesterNG.java: BinTreeNG を利用するプログラム例 === BinTreeNG.java =========================================================================

More information

: : : TSTank 2

: : : TSTank 2 Java (8) 2008-05-20 Lesson6 Lesson5 Java 1 Lesson 6: TSTank1, TSTank2, TSTank3 java 2 car1 car2 Car car1 = new Car(); Car car2 = new Car(); car1.setcolor(red); car2.setcolor(blue); car2.changeengine(jet);

More information

アルゴリズムとデータ構造1

アルゴリズムとデータ構造1 1 2005 7 22 22 (sakai.keiichi@kochi sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2005/index.html tech.ac.jp/k1sakai/lecture/alg/2005/index.html f(0) = 1, f(x) =

More information

r2.dvi

r2.dvi 2002 2 2003.1.29 1 2.1-2.3 (1) (2) 2.4-2.6 (1)OO (2)OO / 2.7-2.10 (1)UML (2) Java 3.1-3.3 (1) (2)GoF (3)WebSphere (4) 3.4-3.5 3.6-3.9 Java (?) 2/12( ) 20:00 2 (2 ) 3 Java (?)1 java.awt.frame Frame 1 import

More information

問題1 以下に示すプログラムは、次の処理をするプログラムである

問題1 以下に示すプログラムは、次の処理をするプログラムである 問題 1 次に示すプログラムは 配列 a の値を乱数で設定し 配列 a の値が 333 より大きく 667 以下の値 の合計値を求めるプログラムである 1 と 2 に適切なコードを記述してプログラムを完 成させよ class TotalNumber { public static void main(string[] args) { int[] a = new int[1000]; // 1 解答条件

More information

2

2 次の課題 1~7 の を埋めてプログラムを完成させよ 1. 整数型の配列に格納されたデータの総和を計算し, その結果を出力するプログラムである このプログラムの処理手順を次に示す 1 配列の格納するデータの個数 n (n>0) を入力する 2n の大きさで配列を確保する 3 配列に n 個分のデータを格納する 4 配列の総和を求める 5 総和を出力する import java.io.*; public

More information

6 p.1 6 Java GUI GUI paintcomponent GUI mouseclicked, keypressed, actionperformed mouseclicked paintcomponent thread, 1 GUI 6.0.2, mutlithread C

6 p.1 6 Java GUI GUI paintcomponent GUI mouseclicked, keypressed, actionperformed mouseclicked paintcomponent thread, 1 GUI 6.0.2, mutlithread C 6 p.1 6 Java GUI GUI paintcomponent GUI mouseclicked, keypressed, actionperformed mouseclicked paintcomponent 6.0.1 thread, 1 GUI 6.0.2, mutlithread CPU 1 CPU CPU +----+ +----+ +----+ Java 1 CPU 6 p.2

More information

ALG2012-C.ppt

ALG2012-C.ppt 2012717 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 1 1. 2. 2 .. 3 public class WeightedNode { private E value; // private Map

More information

9.3 同期 共有データへの読み書きの同期 複数のスレッドから共有データを読み書きするときに発生する問題について 一つのフィールドに対して複数のスレッドが同時にアクセスする可能性がある場合 その順番によっては整合性が保てなくなる可能性があるので スレッドの制御フローが独立していては困ることがある 次

9.3 同期 共有データへの読み書きの同期 複数のスレッドから共有データを読み書きするときに発生する問題について 一つのフィールドに対して複数のスレッドが同時にアクセスする可能性がある場合 その順番によっては整合性が保てなくなる可能性があるので スレッドの制御フローが独立していては困ることがある 次 Java 独習第 3 版 9.3 同期 9.4 デッドロック 9.5 スレッドの通信 2006 年 6 月 21 日 ( 水 ) 南慶典 9.3 同期 共有データへの読み書きの同期 複数のスレッドから共有データを読み書きするときに発生する問題について 一つのフィールドに対して複数のスレッドが同時にアクセスする可能性がある場合 その順番によっては整合性が保てなくなる可能性があるので スレッドの制御フローが独立していては困ることがある

More information

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value = Part2-1-3 Java (*) (*).class Java public static final 1 class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value

More information

ohp02.dvi

ohp02.dvi 172 2017.7.16 1 ? X A B A X B ( )? IBMPL/I FACOM PL1 ( ) X 2 ( ) 3 2-0 ( ) ( ) ( ) (12) ( ) (112) 31) 281 26 1 4 (syntax) (semantics) ( ) 5 BNF BNF(Backus Normal Form) Joun Backus (grammer) English grammer

More information

ALG2012-A.ppt

ALG2012-A.ppt 21279 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/212/index.html (, )ε m = n C2 = n ( n 1) / 2 m = n ( n 1) 1 11 11 111 11 111 111 1111 1 1 11 1 11 11 111 4-dimentional

More information

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。 ソフトウェア基礎演習課題 文法理解度確認範囲 問題 1 データ型 ( 変数, データ型 ) 問題 2 制御構造 (switch 文 ) 問題 3 制御構造 (while 文 ) 問題 4 制御構造と配列 ( 総和 ) 問題 5 制御構造と配列 ( 総和, 平均 ) 問題 6 データ型と各種演算子 ( 文字列, 検索 ) 問題 7 クラスの定義 ( メソッドの定義, コンストラクタの定義, キャスト

More information

6-1

6-1 6-1 (data type) 6-2 6-3 ML, Haskell, Scala Lisp, Prolog (setq x 123) (+ x 456) (setq x "abc") (+ x 456) ; 6-4 ( ) subtype INDEX is INTEGER range -10..10; type DAY is (MON, TUE, WED, THU, FRI, SAT, SUN);

More information

2

2 プログラミング応用演習 b 10 月 5 日演習課題 2016/10/05 PAb 演習課題 プログラム仕様書作成課題 課題クラスを読み 次に示すクラスの仕様書を完成させよ なお 仕様書は クラス 1 つに付き 1 つ作成す る 加えて 図 1 のようなクラス継承の模式図を作成せよ < クラス名 のプログラム仕様書 > 作成者 : 学籍番号 名前 (1) クラスクラス名 : クラス名 説明 : クラスが何を表現しているか

More information

基本情報STEP UP演習Java対策

基本情報STEP UP演習Java対策 トレーニング編 1. 予約語 extends アクセスレベル class サブクラス名 extends スーパクラス名 { (1) スーパクラス ( 既存のクラス ) を拡張して, サブクラス ( 新しいクラス ) を定義する場合に extends を利用する (2) extends の後ろには, スーパクラスの名前を一つだけ指定できる (3) サブクラスからインスタンスを生成すると, スーパクラスに定義されたインスタンス変数やメソッドがこのインスタンス内部に引き継がれる

More information

VB.NETコーディング標準

VB.NETコーディング標準 (C) Copyright 2002 Java ( ) VB.NET C# AS-IS extremeprogramming-jp@objectclub.esm.co.jp bata@gold.ocn.ne.jp Copyright (c) 2000,2001 Eiwa System Management, Inc. Object Club Kenji Hiranabe02/09/26 Copyright

More information

oop1

oop1 public class Car{ int num; double gas; // double distance; String maker; // // // void drive(){ System.out.println(""); Car.java void curve(){ System.out.println(""); void stop(){ System.out.println("");

More information

text_08.dvi

text_08.dvi C 8 12 6 6 8 Java (3) 1 8.1 8 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 8.2 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

More information

Java (5) 1 Lesson 3: x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java , 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) "flow

Java (5) 1 Lesson 3: x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java , 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) flow Java (5) 1 Lesson 3: 2008-05-20 2 x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java 1.1 10 10 0 1.0 2.0, 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) "flowrate.dat" 10 8 6 4 2 0 0 5 10 15 20 25 time (s) 1 1

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅱ 4 回目クラスの機能 (2) コンストラクタ クラス変数 クラスメソッド課題 確認 問題次の各文は正しいか誤っているか答えなさい (1) コンストラクタはメソッドと同様に戻り値をもつ (2) コンストラクタはオブジェクトが生成されると最初に実行される (3) コンストラクタはメソッドと同様にオーバーロードができる (4) コンストラクタは常に public メンバとしなければならない

More information

$ java StoreString abc abc ed abced twice abcedabced clear xyz xyz xyz bingo! abc bingo!abc ^Z mport java.io.*; ublic class StoreString { public static void main(string[] args) throws IOException{ BufferedReader

More information

r02.dvi

r02.dvi 172 2017.7.16 1 1.1? X A B A X B ( )? IBMPL/I FACOM PL1 ( ) X ( ) 1.2 1 2-0 ( ) ( ) ( ) (12) ( ) (112) (131) 281 26 1 (syntax) (semantics) ( ) 2 2.1 BNF BNF(Backus Normal Form) Joun Backus (grammer) English

More information

Java updated

Java updated Java 2003.07.14 updated 3 1 Java 5 1.1 Java................................. 5 1.2 Java..................................... 5 1.3 Java................................ 6 1.3.1 Java.......................

More information

. IDE JIVE[1][] Eclipse Java ( 1) Java Platform Debugger Architecture [5] 3. Eclipse GUI JIVE 3.1 Eclipse ( ) 1 JIVE Java [3] IDE c 016 Information Pr

. IDE JIVE[1][] Eclipse Java ( 1) Java Platform Debugger Architecture [5] 3. Eclipse GUI JIVE 3.1 Eclipse ( ) 1 JIVE Java [3] IDE c 016 Information Pr Eclipse 1,a) 1,b) 1,c) ( IDE) IDE Graphical User Interface( GUI) GUI GUI IDE View Eclipse Development of Eclipse Plug-in to present an Object Diagram to Debug Environment Kubota Yoshihiko 1,a) Yamazaki

More information

Javaセキュアコーディングセミナー東京 第2回 数値データの取扱いと入力値の検証 演習解説

Javaセキュアコーディングセミナー東京 第2回 数値データの取扱いと入力値の検証 演習解説 Japan Computer Emergency Response Team Coordination Center 電子署名者 : Japan Computer Emergency Response Team Coordination Center DN : c=jp, st=tokyo, l=chiyoda-ku, email=office@jpcert.or.jp, o=japan Computer

More information

試験問題に記載されている会社名又は製品名は, それぞれ各社の商標又は登録商標です なお, 試験問題では, 及び TM を明記していません

試験問題に記載されている会社名又は製品名は, それぞれ各社の商標又は登録商標です なお, 試験問題では, 及び TM を明記していません サンプル問題 Java TM プログラミング能力認定試験 3 級 解答時における注意事項 1. 次の表に従って解答してください 問題番号問 1~ 問 6 選択方法 試験時間 6 問必須 60 分 2.HB の黒鉛筆を使用してください 訂正の場合は, あとが残らないように消しゴムできれいに消し, 消しくずを残さないでください 3. 解答用紙の所定の欄に, 級種, 会場コード, 受験番号を記入しマークしてください

More information

明解Java入門編

明解Java入門編 1 Fig.1-1 4 Fig.1-1 1-1 1 Table 1-1 Ease of Development 1-1 Table 1-1 Java Development Kit 1 Java List 1-1 List 1-1 Chap01/Hello.java // class Hello { Java System.out.println("Java"); System.out.println("");

More information

Java講座

Java講座 ~ 第 1 回 ~ 情報科学部コンピュータ科学科 2 年竹中優 プログラムを書く上で Hello world 基礎事項 演算子 構文 2 コメントアウト (//, /* */, /** */) をしよう! インデントをしよう! 変数などにはわかりやすい名前をつけよう! 要するに 他人が見て理解しやすいコードを書こうということです 3 1. Eclipse を起動 2. ファイル 新規 javaプロジェクト

More information

2

2 問題 次の設問に答えよ 設問. Java のソースコードをコンパイルするコマンドはどれか a) java b) javac c) javadoc d) javaw 設問. Java のバイトコード ( コンパイル結果 ) を実行するコマンドはどれか a) java b) javac c) javadoc d).jar 設問. Java のソースコードの拡張子はどれか a).c b).java c).class

More information

** 平成 16 年度 FE 午後問題 Java** 示現塾プロジェクトマネージャ テクニカルエンジニア ( ネットワーク ) など各種セミナーを開催中!! 開催日 受講料 カリキュラム等 詳しくは 今すぐアクセス!! 平成 16

** 平成 16 年度 FE 午後問題 Java** 示現塾プロジェクトマネージャ テクニカルエンジニア ( ネットワーク ) など各種セミナーを開催中!! 開催日 受講料 カリキュラム等 詳しくは   今すぐアクセス!! 平成 16 平成 16 年度春期 FE 午後問題 Java 問 8 次の Java プログラムの説明及びプログラムを読んで, 設問に答えよ プログラムの説明 このプログラムは, 数量の単位変換を行う共通機能を提供するクラス群と, それらのテストプログラムからなる テストプログラムでは, セルシウス温度 ( セ氏温度, ) 及びカ氏温度 ( F ) の変換を行うクラスを利用する (1) インタフェース Converter

More information

文字列操作と正規表現

文字列操作と正規表現 文字列操作と正規表現 オブジェクト指向プログラミング特論 2018 年度只木進一 : 工学系研究科 2 文字列と文字列クラス 0 個以上の長さの文字の列 Java では String クラス 操作 文字列を作る 連結する 文字列中に文字列を探す 文字列中の文字列を置き換える 部分文字列を得る 3 String クラス 文字列を保持するクラス 文字列は定数であることに注意 比較に注意 == : オブジェクトとしての同等性

More information

ex01.dvi

ex01.dvi ,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) double

More information

(Microsoft PowerPoint - \223\306\217KJAVA\221\346\202R\224\ ppt)

(Microsoft PowerPoint - \223\306\217KJAVA\221\346\202R\224\ ppt) 独習 JAVA 第 3 版 8.4 例外とエラークラス 8.5 throws ステートメント 8.6 独自の例外 Throwable コンストラクタ catch ブロックには Throwable 型のパラメータが必ず 1 つなければならない Throwable コンストラクタ Throwable() Throwable( String message ) message には問題を通知する文字列のメッセージ

More information

コーディング基準.PDF

コーディング基準.PDF Java Java Java Java.java.class 1 private public package import / //////////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////////////

More information

tkk0408nari

tkk0408nari SQLStatement Class Sql Database SQL Structured Query Language( ) ISO JIS http://www.techscore.com/tech/sql/02_02.html Database sql Perl Java SQL ( ) create table tu_data ( id integer not null, -- id aid

More information

Microsoft Word - keisankigairon.ch doc

Microsoft Word - keisankigairon.ch doc 1000000100001010 1000001000001011 0100001100010010 1010001100001100 load %r1,10 load %r2,11 add %r3,%r1,%r2 store %r3,12 k = i + j ; = > (* 1 2 3 4 5 6 7 8 9 10) 3628800 DO 3 I=1,3 DO3I=1.3 DO3I 1.3

More information

Make the Future Java FY13 PPT Template

Make the Future Java FY13 PPT Template 1 - 目指せ脱初心者!! - クイズで覚える Java プログラミング 日本オラクル株式会社オラクルユニバーシティ #jdt2014_e3 2 以下の事項は 弊社の一般的な製品の方向性に関する概要を説明するものです また 情報提供を唯一の目的とするものであり いかなる契約にも組み込むことはできません 以下の事項は マテリアルやコード 機能を提供することをコミットメント ( 確約 ) するものではないため

More information

ex01.dvi

ex01.dvi ,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) { double

More information

JAVA とテンプレート

JAVA とテンプレート JAVA とテンプレート 序論 : コンテナ 他のクラスのオブジェクトを保存するものをコンテナ (Container) と呼ぶ 集合 リスト 表 コンテナに求められる機能 追加 削除 参照 要素の比較 並べ替え 要素のクラスが不明では 比較できない 要素が想定しているクラスのものかの判定 テンプレート以前の対応方法 コンテナ設計時に 保存されるクラスを特定してコンテナをコードする 保存されるクラスごとに作成しなければならない

More information

Prog2_9th

Prog2_9th 2013 年 11 月 21 日 ( 木 ) 実施例外処理 Java 言語では, 作成したプログラムを実行する際に, 記述した処理が想定しない事態によって実行できなくなる場合を例外と呼び, その例外への対処, 即ち例外処理が求められる これまでの教材に登場した例外の中で,IOException はコンパイラがチェックするため, 例外処理を必ず記述しなければコンパイルが出来ないものであるのに対して,ArithmeticException

More information

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme 2014 8 01 10:30 12:00 I. I VII II. III. IV. ( a d) V. VI. 80 100 60 : this==null, T == N A ActionListener A addactionlistener C class D actionperformed E ActionEvent G getsource I implements J JApplet

More information

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed 11 7 29 10:30 12:00 I. I VII II. III. IV. ( a d) V. VI. 80 100 60 : this==null, T == N A ActionListener A addactionlistener C class D actionperformed E ActionEvent G getsource I implements J JApplet K

More information

Java プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文

Java プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文 Java プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文字 0x0000 ~ 0xffff byte 1バイト整数 - 2 8 ~ 2 8-1 short 2バイト整数

More information

ALG ppt

ALG ppt 2012614 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 1 2 2 3 29 20 32 14 24 30 48 7 19 21 31 4 N O(log N) 29 O(N) 20 32 14 24 30 48 7 19 21 31 5

More information