extends (*) (*) extend extends 2

Size: px
Start display at page:

Download "extends (*) (*) extend extends 2"

Transcription

1

2 extends (*) (*) extend extends 2

3 class Person { private String name; String name() {return name; Person(String name) { this.name=name; class Worker extends Person { private int salary; Worker(String name, int salary) { super(name); // this.salary = salary; int salary() {return salary; // String who() { return "I am a worker, "+name(); // 3

4 (RDB) entitiy-relationship diagram with ISA ISA = extends 4

5 Integer java.lang java.lang.object +--java.lang.number +--java.lang.integer : Comparable, Serializable ArrayList java.util java.lang.object +--java.util.abstractcollection +--java.util.abstractlist +--java.util.arraylist : Cloneable, Collection, List, RandomAccess, Serializable 5

6 vs Java 6

7 2 7

8 3 CopyC DummyC CopyC class C { private int x; C(int x) {this.x=x; double divide(int y) { return (double)x/y; public static void main(string[] args) { C a = new C(3); System.out.println(a.divide(2)); abstract class CopyC { private int x; CopyC(int x) {this.x=x; double divide(int y) { return (double)x/y; class DummyC extends CopyC { DummyC(int x) {super(x); public static void main(string[] args) { DummyC a = new DummyC(3); System.out.println(a.divide(2)); 8

9 (abstract) class C c extends C p 9

10 class Company { private Employee[] emplist; // FullTime ParTime Company(Employee[] emplist) {this.emplist=emplist; int sumofsalary() { int total = 0; for (int i=0;i<emplist.length;i++) total += emplist[i].salary(); // salary() return total; public static void main(string[] args) { Employee[] emplist = {new FullTime("yoshiko", 10000), new PartTime("taro", 10,30); System.out.println("total = "+(new Company(emplist)).sumOfSalary()); abstract class Employee {// private String name; Employee(String name) {this.name=name;// // // abstract int salary(); // class FullTime extends Employee { private int salary; FullTime(String name, int salary) {// super(name); this.salary = salary; int salary() {return salary; // FullTime // public must be public class PartTime extends Employee { private int hourperday, paymentforhour; PartTime(String name, int hourperday, int paymentforhour) {//PartTime super(name); this.hourperday=hourperday; this.paymentforhour=paymentforhour; int salary() { return hourperday*paymentforhour*20; 10

11 class Company { private Employee[] emplist; int sumofsalary() { int total = 0; for (int i=0;i<emplist.length;i++) total += emplist[i].salary(); return total; interface HasSalary { int salary(); // abstract class Employee implements HasSalary{/* HasSalary */ public abstract int salary(); /* public int salary() {... */ // name // class FullTime extends Employee { private int salary; public int salary() {return salary;//public class PartTime extends Employee { private int hourperday, paymentforhour; public int salary() { return hourperday*paymentforhour*20;//5days/week, 4 week 11

12 single inheritance or multiple inheritance? class C extends P user Object: Object interface IC extends IP 12

13 abstract class Employee { abstract void hellow(); abstract int salary(); class FullTime extends Employee { private int salary; void hellow() {System.out.println( "Hellow, I am a full time worker"); int salary() {return salary; class Employee { void hellow() { // do nothing int salary() {return -1;// nonsense class FullTime extends Employee { private int salary; void hellow() {System.out.println( "Hellow, I am a full time worker"); int salary() {return salary; Employee hellow salary Employee hellow salary 13

14 3.1 extends class P { int x = 1; class C extends P{ int y = 2; // C(int x, int y) { // this.x=x; this.y=y; C(int y) { // this.y=y; C() { // void show() { System.out.println("x="+x+", y="+y); public static void main(string[] args) { (new C()).show(); (new C(200)).show(); (new C(100,200)).show(); /* x=1, y=2 x=1, y=200 x=100, y=200 */ C this.x=x; x top class Object 14

15 class P { private int x; int getx() {return x; P(int x) {this.x = x; class C extends P { private int y; // C(int x, int y) { super(x); this.y=y; void show() { System.out.println( "x="+getx()+", y="+y); public static void main(string[] args) { (new C(100,200)).show(); Read super(int) int x void setx(int x) {this.x=x; C(int x, int y) { this.setx(x); this.y=y; P(int) (*) (*) P() P() { 15

16 generic Object java.util.arraylist capacity generic ArrayList ArrayList<String> abc ArrayList String LinkedList import java.util.arraylist; class Afo { public static void main(string args[]){ ArrayList<String> slist = new ArrayList<String>(); slist.add("abc"); System.out.println(slist.get(0)); // ArrayList list = new ArrayList(); // arraylist of object list.add("abc"); // String str = slist.get(0); // compile error. slist.get(0) object String str1 = (String)list.get(0); // System.out.println(str1); 16

17 generic type import java.util.arraylist; interface Showable { void show(); interface SortableObj extends Showable { String name(); int code(); abstract class Sorter { abstract boolean lessthan(sortableobj x, SortableObj y); abstract boolean equals(sortableobj x, SortableObj y); void swap(arraylist<sortableobj> inputdata) {// if (lessthan(inputdata.get(0),inputdata.get(1))) return; SortableObj tmp = inputdata.get(1); inputdata.set(1, inputdata.get(0)); inputdata.set(0, tmp); void show(arraylist<sortableobj> inputdata) { for (int i=0;i<inputdata.size();i++) inputdata.get(i).show(); System.out.println(); class SortedByCode extends Sorter{ boolean lessthan(sortableobj x, SortableObj y) {return x.code() < y.code(); boolean equals(sortableobj x, SortableObj y) {return x.code() == x.code(); class SorterByName extends Sorter{ boolean lessthan(sortableobj x, SortableObj y) {return x.name().compareto(y.name()) <0; boolean equals(sortableobj x, SortableObj y) {return x.name().compareto(x.name()) == 0; // public // // 17

18 class St implements SortableObj { private int code; public int code() {return code; private String name; public String name() {return name; public void show() {System.out.print(name+"("+code+"),"); St(int i, String name) {code = i;this.name=name; // java St code 103 katoh 101 okubo 102 saitoh // java St name 101 okubo 103 katoh 102 saitoh public static void main(string args[]){ ArrayList<SortableObj> data = new ArrayList<SortableObj>(args.length/2); for (int i=0;i<(args.length-1)/2;i++) { St st = new St(Integer.parseInt(args[2*i+1]),args[2*i+2]); data.add(st); ; Sorter sorter; if (args[0].equals("code")) sorter = new SortedByCode(); else if (args[0].equals("name")) sorter = new SorterByName(); else sorter = null;// sorter.swap(data); sorter.show(data); 18

19 C 1 ( ) C 2 ( ) (abstract) class C 1 extends C 2 interface B extends B 1,..., B k (*) (**) (abstract) class C 1 extends C 2 implements B 1,..., B k (*) (**) abstract class A implements B 19

20 τ m (σ 1 x 1,..., σ n x n ) τ m (σ 1,..., σ n ) class O3 { void f() { System.out.println("o3"); class O2 extends O3 { void f() { System.out.println("o2"); class O1 extends O2 { void f() { System.out.println("o1"); public static void main(string args[]){ O2 x = new O1(); x.f(); // (*) (*) x O2 O1 O1 f() 20

21 abstract method public (*) implements B satisfied. So, implements (**) 21

22 /* holders.holder(coin.index()): coin Holders transaction: Holders stock Holder Symbol subclass interface Symbols Symbols String name Symbols */ abstract class Symbol {// Item Coin Cancel private String name; String name() {return name; Symbol(String n) {name = n; abstract void message();// class Item extends Symbol{ private int price; int price() {return price; Item(String n, int p) {super(n); price=p; void message() {System.out.println(" "+name()+" ("+price+" ) "); class Coin extends Symbol{ private int value; int value() {return value; Coin(String name, int v) {super(name); value=v; private int index;//holder holders int index() {return index; void setindex(int x) {index = x; void message() {System.out.println(" "+value+" "); class Cancel extends Symbol { Cancel(String n) {super(n); void message() {System.out.println(" "); 22

23 interface Symbols { Coin c10 = new Coin("c10",10), c50 = new Coin("c50",50), c100 = new Coin("c100",100), c500 = new Coin("c500",500); Coin[] coins = {c10,c50,c100,c500;// // Cancel cancel = new Cancel("cancel"); Item orangejuice = new Item("orange juice", 80), bosscoffee = new Item("boss coffee", 120), healthymilk = new Item("healthy milk", 60); Symbol[] symbols = {c10, c50, c100, c500, cancel, orangejuice, bosscoffee, healthymilk ; /* SymbolProcess VendingMachine */ ImplementationOfSymbols ios = new ImplementationOfSymbols(); Symbol stringtosymbol(string arg); void checkcoins(); class ImplementationOfSymbols implements Symbols { public Symbol stringtosymbol(string arg) { for (int j=0; j<symbols.length; j++) if (symbols[j].name().equals(arg)) return symbols[j]; System.out.println(" *** "+arg); return null; public void checkcoins() {// Symbols.coins int max = 0; for (int i=0;i<coins.length;i++) if (max < coins[i].value()) { coins[i].setindex(i); max = coins[i].value(); else { System.out.println(" *** Symbols.coins "); System.exit(1); ; 23

24 class Holder {/* stock, transaction */ private Coin coin; Coin coin() {return coin; private int nof = 0; // void count() {nof++; int nof() {return nof; void add(int x) {nof += x; void subtract(int x){nof -= x; void reset() {nof=0; int amount() {return nof * coin.value(); void returncoin(int x) { if (x == 0) return; nof -= x; System.out.println(" "+coin.value()+" "+x+" "); Holder(Coin coin) {this.coin = coin; class VendingMachine implements Symbols{ public Symbol stringtosymbol(string arg) {return ios.stringtosymbol(arg); public void checkcoins() {ios.checkcoins(); // private Holders stock, transaction; VendingMachine() { checkcoins(); stock = new Holders(); transaction = new Holders(); class Holders {// private Holder[] holders = new Holder[coins.length]; private Holders() { for (int i=0;i<coins.length;i++) holders[i] = new Holder(coins[i]); private Holder holder(coin coin) {return holders[coin.index()]; private int totalamount() { int sum = 0; for (int i=0;i<holders.length;i++) sum += holders[i].amount(); return sum; private void returnallcoin() { for (int i=0;i<coins.length;i++) holders[i].returncoin(holders[i].nof()); // end Holders 24

25 private void paybackchange(int amount) { int[] paybacknof = new int[coins.length]; for (int i=coins.length-1;i>=0;i--) { paybacknof[i] = Math.min(amount/(coins[i].value()), stock.holder(coins[i]).nof()+transaction.holder(coins[i]).nof()); amount -= paybacknof[i] * coins[i].value(); ; if (amount > 0) { System.out.println(" "); transaction.returnallcoin(); return; ; System.out.println(" "); for (int i=0;i<coins.length;i++) { stock.holder(coins[i]).add(transaction.holder(coins[i]).nof()); transaction.holder(coins[i]).reset(); stock.holder(coins[i]).returncoin(paybacknof[i]); ; void process(symbol input) { input.message(); if (input instanceof Cancel) { transaction.returnallcoin(); System.out.println("+++ "); return; ; if (input instanceof Coin) { transaction.holder((coin)input).count(); return; ; if (input instanceof Item) { int difference = ((Item)input).price()-transaction.totalAmount(); if (difference > 0) { System.out.println(" "+difference+" "); return;// ; paybackchange( -difference ); System.out.println(" ++ "); ; 25

26 int sales() {return stock.totalamount(); class test { public static void main(string args[]){ VendingMachine vm = new VendingMachine(); Symbol input; for (int i=0;i<args.length;i++) if ((input = vm.stringtosymbol(args[i]))!=null) vm.process(input); System.out.println(" ++ "+ vm.sales()); //java test c10 c10 c100 "boss coffee" c100 "orange juice" c100 "healthy milk" c1000 c50 c10 c10 "healthy milk" boss coffee (120 ) orange juice (80 ) healthy milk (60 ) *** c healthy milk (60 ) instanceof void process(symbol) instanceof Symbol instanceof instanceof 26

27 C.main interface A {int f(); class B { int g(a a) {return 100+a.f(); final class C extends B implements A { private int y; C(int y) {this.y=y; public int f() {return y; public static void main(string args[]){ C c = new C(100); System.out.println(c.g(c)); 27

28 StudentRecordForLecture, StudentRecordForExercise Lecture, Exercise StudentRecordForLecture StudentRecordForExercise Item (A1) (A2) (A3) ( ) Exercise Exercise(String, StudentRecordForExercise[]) Exercise StudentRecordForExercise ( ) double avg() Lecture Excercise

29 1. abstract class StudentRecord { 2. private String name;// 3. abstract double score(); 4. StudentRecord(String name) {this.name=name; class StudentRecordForLecture extends StudentRecord{ 7. private int score;// 8. double score() {return score; 9. StudentRecordForLecture(String name, int score) { 10. super(name); this.score = score; class StudentRecordForExercise extends StudentRecord{ 14. private static final int noftimes = 12; 15. private int[] scores; 16. StudentRecordForExercise(String name, int[] rs) { 17. super(name); scores = rs; // rs.length == // 19. double score() { 20. double sum = 0.0; 21. for (int i=0;i<noftimes;i++) sum += scores[i]; 22. return sum/noftimes; abstract class Item { 26. private String name;// 27. private StudentRecord[] records; 28. Item(String name, StudentRecord[] records) { 29. this.name = name; this.records = records; double avg() { // 32. double sum = 0.0; 33. for (int i=0; i<records.length;i++) sum += records[i].score(); 34. return sum/records.length; class Lecture extends Item { 38. Lecture(String name, StudentRecordForLecture[] records) { 39. super(name, records); class Exercise extends Item{ 43. Exercise(String name, StudentRecordForExercise[] records) { ( )

30 java A = {(a,1),(b,3),(c,2) class ArrayList extends ArrayList ArrayList public methods ( ): size(): ArrayList(): add(object x): x Object Object get(int j): j ObjectWithEquality ArrayList new MultiSet() multisetadd ObjectWithEquality public static void main(string args[]) super ArrayList add MultiSet add 30

31 import java.util.arraylist; // class ObjectWithCounter { private ObjectWithEquality value; ObjectWithEquality getvalue() {return value; private int counter=1; void countone() {counter++; int getcounter() {return counter; ObjectWithCounter(ObjectWithEquality owe) {value=owe; interface ObjectWithEquality { boolean equals(objectwithequality x); class MultiSet extends ArrayList { private int totalnumber = 0; int gettotalnumber() {return totalnumber; void multisetadd(objectwithequality owequality) { ObjectWithCounter owcounter; if (size()==0 (owcounter = checkmembership(owequality))==null ) add(new ObjectWithCounter(owEquality)); else owcounter.countone(); totalnumber++; private ObjectWithCounter checkmembership(objectwithequality owequality) { ObjectWithCounter owcounter; for (int i=0;i<size();i++) if (( owcounter = (ObjectWithCounter)get(i) ). getvalue().equals(owequality)) return owcounter; return null; 31

DVIOUT-exer

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

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

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

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

1.1 (1) (2) (3) (4) 2

1.1 (1) (2) (3) (4) 2 1 Part2-1-1 1 1.1 (1) (2) (3) (4) 2 2 JAVA (*) Java : 1. Java 2. 3. 4. Java Java 3 3 int[] a; a = new int[3]; new int[3] a i a[i] 32bit a[i] 4 4 class Point { // double x, y, weight; // Point(double x,

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

新・明解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

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

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

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

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

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演習(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

{: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 (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

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によるアルゴリズムとデータ構造

明解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

JavaプログラミングⅠ

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

More information

今回の内容 グラフとオブジェクト指向プログラミング Java を使う理由 Java の基本 Javaのライブラリ 開発 実行 クラスの再利用 クラス継承 抽象クラス 開発の要点

今回の内容 グラフとオブジェクト指向プログラミング Java を使う理由 Java の基本 Javaのライブラリ 開発 実行 クラスの再利用 クラス継承 抽象クラス 開発の要点 JAVA 入門 今回の内容 グラフとオブジェクト指向プログラミング Java を使う理由 Java の基本 Javaのライブラリ 開発 実行 クラスの再利用 クラス継承 抽象クラス 開発の要点 グラフを記述するには 頂点 (Vertex) と弧 (Arc) その間の関係 素直にデータ構造として表現したい グラフは 頂点と弧の集合 弧から始点と終点を得る 頂点から その頂点を始点とする弧の集合を得る

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

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

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

解きながら学ぶ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

text_08.dvi

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

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

オブジェクト脳のつくり方

オブジェクト脳のつくり方 2003 12 16 ( ) ML Java,.NET, UML J2EE, Web Java, J2EE.NET SI ex. ) OO OO OO OO OO (Controller) (Promoter) (Analyzer) (Supporter) http://nba.nikkeibp.co.jp/coachsp.html It takes time. OO OK OO 1.

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

10K pdf

10K pdf #1 #2 Java class Circle { double x; // x double y; // y double radius; // void set(double tx, double ty){ x = tx; y = ty; void set(double tx, double ty, double r) { x = tx; y = ty; radius = r; // Circle

More information

ALG ppt

ALG ppt 2012 7 5 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html (198 ) f(p) p 2 1 2 f 2 53 12 41 69 11 2 84 28 31 63 97 58 76 19 91 88 53 69 69 11 84 84 63

More information

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

問題1 以下に示すプログラムは、次の処理をするプログラムである 問題 1 次のプログラムの出力結果を a~d の中から選べ public class Problem1 { int i=2; int j=3; System.out.println("i"+j); a) 23,b) 5,c) i3,d) ij 問題 2 次のプログラムの出力結果を a~d の中から選べ public class Problem2 { int a=6; if((a>=2)&&(a

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

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

文字列操作と正規表現

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

More information

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

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

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

基本情報STEP UP演習Java対策

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

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 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

Javaセキュアコーディングセミナー東京 第3回 入出力(File, Stream)と例外時の動作 演習解説

Javaセキュアコーディングセミナー東京 第3回 入出力(File, Stream)と例外時の動作 演習解説 Java セキュアコーディングセミナー東京第 3 回入出力と例外時の動作 演習解説 2012 年 11 月 11 日 ( 日 ) JPCERT コーディネーションセンター脆弱性解析チーム戸田洋三 1 Hands-on Exercises コンパイルエラーに対処しよう ファイルからのデータ入力を実装しよう 2 Hands-on Exercise(1) サンプルコードの コンパイルエラーに対処しよう 3

More information

1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3

1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3 1 2 2 1 2 2.1.................................................... 2 2.2.................................................... 2 2.3........................................ 2 2.4....................................................

More information

3 p.1 3 Java Java Java try catch C Java if for while C 3.1 boolean Java if C if ( ) 1 if ( ) 1 else , 2 { } boolean true false 2 boolean Gr

3 p.1 3 Java Java Java try catch C Java if for while C 3.1 boolean Java if C if ( ) 1 if ( ) 1 else , 2 { } boolean true false 2 boolean Gr 3 p.1 3 Java Java Java try catch C Java if for while C 3.1 boolean Java if C if ( ) 1 if ( ) 1 else 2 1 1 2 2 1, 2 { boolean true false 2 boolean Graphics draw3drect fill3drect C int C OK while (1)...

More information

2

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

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

JavaプログラミングⅠ

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

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

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

: : : 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

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

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

2 static final int DO NOTHING ON CLOSE static final int HIDE ON CLOSE static final int DISPOSE ON CLOSE static final int EXIT ON CLOSE void setvisible

2 static final int DO NOTHING ON CLOSE static final int HIDE ON CLOSE static final int DISPOSE ON CLOSE static final int EXIT ON CLOSE void setvisible 12 2013 7 2 12.1 GUI........................... 12 1 12.2............................... 12 4 12.3..................................... 12 7 12.4....................................... 12 9 12.5 : FreeCellPanel.java............................

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

問題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

7 プログラムの説明を読んで, プログラムの (1)(5) を答えなさい < プログラムの説明 > 処理内容 CSV ファイル ( 作品名データと入場者数データ ) を読み, 年齢区分ごとの入場者数と売上金額を表示するプログラムである 入力データ作品名データ ( ファイル名 :movie.csv)

7 プログラムの説明を読んで, プログラムの (1)(5) を答えなさい < プログラムの説明 > 処理内容 CSV ファイル ( 作品名データと入場者数データ ) を読み, 年齢区分ごとの入場者数と売上金額を表示するプログラムである 入力データ作品名データ ( ファイル名 :movie.csv) プログラミング部門 1 級 無断転載禁止 2013 年月日実施 この問題は, 平成 25 年 2 月時点の参考資料です 平成 25 年度 ( 新検定基準による言語選択問題 Java, マクロ言語の出題例 ) 情報処理検定試験 第 1 級試験問題 注意事項 1. 監督者の指示があるまで, 試験問題に手を触れないでください 2. 試験問題は,10 ページあります 3. 解答はすべて解答用紙に記入します

More information

Java演習(2) -- 簡単なプログラム --

Java演習(2)   -- 簡単なプログラム -- Java public class Hello Hello (class) (field)... (method)... Java main Hello World(Hello.java) public class Hello { public static void main(string[ ] args) { public() (package) Hello World(Hello.java)

More information

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

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

More information

A B 1: Ex. MPICH-G2 C.f. NXProxy [Tanaka] 2:

A B 1: Ex. MPICH-G2 C.f. NXProxy [Tanaka] 2: Java Jojo ( ) ( ) A B 1: Ex. MPICH-G2 C.f. NXProxy [Tanaka] 2: Java Jojo Jojo (1) :Globus GRAM ssh rsh GRAM ssh GRAM A rsh B Jojo (2) ( ) Jojo Java VM JavaRMI (Sun) Horb(ETL) ( ) JPVM,mpiJava etc. Send,

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

untitled

untitled 21174 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/211/index.html tech.ac.jp/k1sakai/lecture/alg/211/index.html html (, )ε m = n C2 = n ( n 1) / 2 m = n ( ( n

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

Q&A集

Q&A集 & ver.2 EWEB-3C-N080 PreSerV for Web MapDataManager & i 1... 1 1.1... 1 1.2... 2 1.3... 6 1.4 MDM. 7 1.5 ( )... 9 1.6 ( )...12 1.7...14 1.8...15 1.9...16 1.10...17 1.11...18 1.12 19 1.13...20 1.14...21

More information

リファレンス,配列 例外処理

リファレンス,配列 例外処理 リファレンス, 配列, 例外処理 その他演習に役立つこと 2004 年 7 月 21 日 海谷治彦 1 リファレンス ま, 改め紹介しなくても Java 遣いなら誰でもつかってる. インスタンスをプログラム中から識別 ( 捕獲 ) するためのラベルのようなもの. C でいうところのポインタ変数に相当. Java では, あるインスタンスを参照するリファレンスが 1 つもなくなると, 勝手にインスタンスは消去される.

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

IE6 2 BMI chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chap

IE6 2 BMI chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chap 1-1 1-2 IE6 2 BMI 3-1 3-2 4 5 chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chapter8 : 13-1 13-2 14 15 PersonTest.java KazuateGame.java

More information

2. データ構造ヒープに保存するデータは 番号付けられて保存される 従って リスト L として保存することとする 3. アルゴリズム 3.1. 要素の追加新しい要素の追加は リストの終端に置くことで開始する つまり 最下層の一番右 または新たに最下層を生成してその一番左となる この後 この要素を正し

2. データ構造ヒープに保存するデータは 番号付けられて保存される 従って リスト L として保存することとする 3. アルゴリズム 3.1. 要素の追加新しい要素の追加は リストの終端に置くことで開始する つまり 最下層の一番右 または新たに最下層を生成してその一番左となる この後 この要素を正し 1. はじめに 二分木ヒープ 様々なアルゴリズムにおいて ある要素の集合またはリストから 最小 な要素を取り 出す必要がある そのような場合に使われる標準的データ構造が二分木ヒープ (binary heap) である あるオブジェクトO を考える そのオブジェクトは ラベル O. label と値 O. value を持つとする このようなオブジェクトを保存する二分木ヒープについて考える 二分木ヒープは以下の二つの制約のある二分木である

More information

Program Design (プログラム設計)

Program Design  (プログラム設計) 7. モジュール化設計 内容 : モジュールの定義モジュールの強度又は結合力モジュール連結モジュールの間の交信 7.1 モジュールの定義 プログラムモジュールとは 次の特徴を持つプログラムの単位である モジュールは 一定の機能を提供する 例えば 入力によって ある出力を出す モジュールは 同じ機能仕様を実装しているほかのモジュールに置き換えられる この変化によって プログラム全体に影響をあまり与えない

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

Exam : 1z0-809 日本語 (JPN) Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO 1 / 8 Get Latest & Valid 1z0-809-JPN Exam's Question and Answe

Exam : 1z0-809 日本語 (JPN) Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO 1 / 8 Get Latest & Valid 1z0-809-JPN Exam's Question and Answe Actual4Test http://www.actual4test.com Actual4test - actual test exam dumps-pass for IT exams Exam : 1z0-809 日本語 (JPN) Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO 1 / 8 Get Latest &

More information

Prog1_10th

Prog1_10th 2014 年 6 月 19 日 ( 木 ) 実施 例外処理 Java 言語では, 作成したプログラムを実行する際に, 記述した処理が想定しない事態によって実行できなくなる場合を例外と呼び, その例外への対処, 即ち例外処理が求められる 例外処理を行うための try 文の一般形は次のようになる 例外を発生させる可能性のある処理 catch( 例外のクラス名 1 変数 1 ) 例外に対処する処理 1 catch(

More information

Microsoft Word - NonGenList.doc

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

More information

ohp07.dvi

ohp07.dvi 17 7 (2) 2017.9.13 1 BNF BNF ( ) ( ) 0 ( ) + 1 ( ) ( ) [ ] BNF BNF BNF prog ::= ( stat ) stat ::= ident = expr ; read ident ; print expr ; if ( expr ) stat while ( expr ) stat { prog expr ::= term ( +

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

JavaプログラミングⅠ

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

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

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

Microsoft Word - NonGenTree.doc

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

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

DVIOUT-interface-he

DVIOUT-interface-he インタフェース プログラム理論と言語 Part2-1-3 Java インタフェース : クラスとしての解釈 (*): 指定された型のメソッド群を持つ もの インタフェースのメソッド : メソッド名と型情報のみの 抽象メソッド 実装クラスでの実装 ( 具体化 ) の義務インタフェースの利用 : もの そのものでなく もの が持つ操作の名前と型のみで処理を記述 処理コードの抽象化 汎用で再利用度が高い

More information

1. はじめに 二分木ヒープ 様々なアルゴリズムにおいて ある要素の集合またはリストから 最小 な要素を取り 出す必要がある そのような場合に使われる標準的データ構造が二分木ヒープ (binary heap) である あるオブジェクトO を考える そのオブジェクトは ラベル O. label と値

1. はじめに 二分木ヒープ 様々なアルゴリズムにおいて ある要素の集合またはリストから 最小 な要素を取り 出す必要がある そのような場合に使われる標準的データ構造が二分木ヒープ (binary heap) である あるオブジェクトO を考える そのオブジェクトは ラベル O. label と値 1. はじめに 二分木ヒープ 様々なアルゴリズムにおいて ある要素の集合またはリストから 最小 な要素を取り 出す必要がある そのような場合に使われる標準的データ構造が二分木ヒープ (binary heap) である あるオブジェクトO を考える そのオブジェクトは ラベル O. label と値 O. value を持つ とする このようなオブジェクトを保存する二分木ヒープについて考える 二分木ヒープは以下の二つの制約のある二分木である

More information

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

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

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

Vector Vector Vector Vector() Vector(int n) n Vector(int n,int delta) n delta

Vector Vector Vector Vector() Vector(int n) n Vector(int n,int delta) n delta Java VectorEnumeration Stack Hashtable StringTokenizer Vector Vector Vector Vector() Vector(int n) n Vector(int n,int delta) n delta Vector Vector void addelement(object obj) int capacity() Object clone()

More information

r1.dvi

r1.dvi 2006 1 2006.10.6 ( 2 ( ) 1 2 1.5 3 ( ) Ruby Java Java Java ( Web Web http://lecture.ecc.u-tokyo.ac.jp/~kuno/is06/ / ( / @@@ ( 3 ) @@@ : ( ) @@@ (Q&A) ( ) 1 http://www.sodan.ecc.u-tokyo.ac.jp/cgi-bin/qbbs/view.cgi

More information

二分木ヒープとは 集合 リストから 最小な 要素を取り出す 二分木ヒープは そのための標準的データ構造 二分木ヒープを保存するデータ構造 二分木ヒープの操作のメソッド 対象となるデータクラス 識別のためのlabelフィールド 値を保持するvalueフィールド

二分木ヒープとは 集合 リストから 最小な 要素を取り出す 二分木ヒープは そのための標準的データ構造 二分木ヒープを保存するデータ構造 二分木ヒープの操作のメソッド 対象となるデータクラス 識別のためのlabelフィールド 値を保持するvalueフィールド 二分木ヒープ (BINARY HEAP) 二分木ヒープとは 集合 リストから 最小な 要素を取り出す 二分木ヒープは そのための標準的データ構造 二分木ヒープを保存するデータ構造 二分木ヒープの操作のメソッド 対象となるデータクラス 識別のためのlabelフィールド 値を保持するvalueフィールド 二分木ヒープとは どういう二分木か ある頂点の要素 pのvalueは その子 cの要素のvalueより大きくない

More information

r3.dvi

r3.dvi 10 3 2010.9.21 1 1) 1 ( 1) 1: 1) 1.0.1 : Java 1 import java.awt.*; import javax.swing.*; public class Sample21 extends JPanel { public void paintcomponent(graphics g) { g.setcolor(new Color(255, 180, 99));

More information

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

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

More information

I 4 p.2 4 GUI java.awt.event.* import /* 1 */ import mouseclicked MouseListener implement /* 2 */ init addmouselistener(this) this /* 3 */ this mousec

I 4 p.2 4 GUI java.awt.event.* import /* 1 */ import mouseclicked MouseListener implement /* 2 */ init addmouselistener(this) this /* 3 */ this mousec I 4 p.1 4 GUI GUI GUI 4.1 4.1.1 MouseTest.java /* 1 */ public class MouseTest extends JApplet implements MouseListener /* 2 */ { int x=50, y=20; addmouselistener(this); /* 3 */ public void mouseclicked(mouseevent

More information

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション L2: Fundamentals of AI Programming in Java Javaアプレット ArrayList HashMap AI 応用の例 探索問題 Java アプレット VS アプリケーション ava アプレットとは html に貼り付けられる java で作成した小規模のプログラムのことで サーバー側からクライアントマシンに送られ ブラウザ上に読み込まれて実行される ブラウザと

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

解答上の注意 1 解答は 解答 紙の問題番号に対応した解答欄にマークしなさい 2 選択肢は 問ごとに 意されています 問 1の選択肢は 問 2で使 しません 3 選択肢は量が多いため 探しやすさの観点よりグループ分けされています グループ分けに合わせて解答欄が区切られていますが 横 1 列で問題 1

解答上の注意 1 解答は 解答 紙の問題番号に対応した解答欄にマークしなさい 2 選択肢は 問ごとに 意されています 問 1の選択肢は 問 2で使 しません 3 選択肢は量が多いため 探しやすさの観点よりグループ分けされています グループ分けに合わせて解答欄が区切られていますが 横 1 列で問題 1 解答上の注意 1 解答は 解答 紙の問題番号に対応した解答欄にマークしなさい 2 選択肢は 問ごとに 意されています 問 1の選択肢は 問 2で使 しません 3 選択肢は量が多いため 探しやすさの観点よりグループ分けされています グループ分けに合わせて解答欄が区切られていますが 横 1 列で問題 1つ分となっています 4 問題の 中の 1 2 などには 特に指 がないかぎり 与えられた 問選択肢群が

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

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

オブジェクト指向プログラミング・同演習 5月21日演習課題

オブジェクト指向プログラミング・同演習 5月21日演習課題 オブジェクト指向プログラミング 同演習 5 月 21 日演習課題 問題 1 配列の例外処理例外が発生する可能性のある処理を try で囲み その後に catch で例外を捕捉します 例外処理の終了処理として finally が行われます これは書かなくて自動的に行われます 提出課題 1 (Kadai052301.java) 以下のプログラムは例外処理をしていない ArrayIndexOutOfBoundsException

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

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

問 次の 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

ユニット・テストの概要

ユニット・テストの概要 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

presen.gby

presen.gby kazu@iij.ad.jp 1 2 Paul Graham 3 Andrew Hunt and David Thomas 4 5 Java 6 Java Java Java 3 7 Haskell Scala Scala 8 9 Java Java Dean Wampler AWT ActionListener public interface ActionListener extends EventListener

More information

untitled

untitled JCSP CSP HPC H.Nakahara 1 2 CSP A B HPC H.Nakahara 3 CSP HPC H.Nakahara 4 CSP Process A chan Process B ( DFD) HPC H.Nakahara 5 DFD HPC H.Nakahara 6 DFD FAX OK? HPC H.Nakahara 7 HPC H.Nakahara 8 HPC H.Nakahara

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