Java学習教材

Size: px
Start display at page:

Download "Java学習教材"

Transcription

1 Java 2016/4/17

2 Java 1 Java1 : 280 : (2010/1/29) ISBN-10: ISBN-13: /1/29

3 1 Java

4 1 Java

5 Java Java class FirstExample { public static void main(string[] args) { System.out.println(" ");

6 Java

7 Java Java Windows MacOS Linux OS

8 C/C++ 1/2 B (#include # #if #ifdef ) C/C++

9 C/C++ 2/2 B boolean true/false new int[] a = new int[5]; String String str = "Hello"; C/C++

10 Java class { public static void main(string[] args) { Example public static void main(string[] args) { {

11 Java class FirstExample { public static void main(string[] args) { System.out.println(" ");

12 class FirstExample { public static void main(string[] args) { System.out.println(" "); { 1 1 {

13 /* */ class FirstExample { public static void main(string[] args) { // System.out.println(" "); 1 /* */ 2 // 1

14 1 > javac FirstExample.java > java FirstExample 2 Eclipse

15 Eclipse 1. [ ] [ ] [Java ] 2. [ ] [ ] [ ] 3. [ ] [ ] [Java ]

16 Compile Error (0) (o) (1) (I) (;) (:) (.) (,)

17 .java.class FirstExample.java.class FirstExample.class Eclipse workspace

18 1.Java 2. Java 3.FirstExample.java 4..java.class

19 2 Java

20 Ecli System.out.println( class FirstExample { public static void main(string[] args) { System.out.println(" ");

21 System.out.println( " "Java " ");

22 1. 2. System.out.println 3. "Java "

23 int i; // i = 5; // System.out.println(i); //

24

25 ; 1 int i; 2 double d; 3 boolean boo = false; 4 char c = ' ';

26 Java

27 1. double boolean char class Example { public static void main(string args[]) { int i; i = 5; System.out.println(i);

28 System.out.println(2 + 3);

29 - *,/ System.out.println(3 + 6 / 3); // 5 System.out.println((3 + 6) /3); // 3

30 class Example { public static void main(string args[]) { System.out.println(2 + 3);

31 int i = 10; int j = i * 2; System.out.println(j); // 20 int i = 10; i = i + 3; System.out.println(i); // 13 int i = 10; i += 3; // System.out.println(i); // 13

32

33 1. a = a + 5; 2. b = b - 6; 3. c = c * a; 4. d = d / 3; 5. e = e % 2; 6. f = f + 1; 7. g = g - 1;

34 class CalcExample3 { public static void main(string[] args) { int i; i = 11; i++; i /= 2; System.out.println("i " + i); int j; j = i * i; System.out.println("j " + j);

35 i = 2 + 3; i = int i; int j = (i = 2 + 3) * 2; System.out.println(i); // 5 System.out.println(j); // 10

36 i++; ++i; i 1 j=i++; j=++i; j j = i; i = i + 1; i = i + 1; j = i;

37 int i = 10; int j = i++; int k = ++i; System.out.println(i); System.out.println(j); System.out.println(k);

38 double > int

39 double d = 9.8; int i = d; double d = 9.8; int i = (int)d; (double) (int)

40 int i = 5; double d = 0.5; System.out.println(i + d); // 5.5 double

41 int a = 5; int b = 2; double c = a / b; System.out.println(c); // 2.0 5/2 2 d double c = (double)a/(double)b;

42 class Example { public static void main(string[] args) { int a = 7; int b = 2; double d = a / b; System.out.println(d);

43 String String String s; s = " "; System.out.println(s); + String s1 = " "; String s2 = " String s3 = s1 + s2; System.out.println(s3);

44 3

45 if( ) { ; if( ) { ; // true

46 if(age < 20) { System.out.println("

47 2 true false

48 1. a a a 4. a 5. a 3 6. a 7. a 5 2

49 if else if( ) { ; else { ; if( ) { // true 1 ; else { // false 2 ;

50 if else int age; age = 20; if(age < 20) { System.out.println(" "); else { System.out.println("

51 if else if else int age; age = 20; if(age < 4) { System.out.println(" else if(age < 13) { System.out.println(" else { System.out.println("

52

53 if else if( == ) { if( == true) { else { else {

54 a 3, 5, 8, 9, 10, 15, 20 if(a < 5) { System.out.println("A"); else if(a < 9) { System.out.println("B"); else if(a < 15) { System.out.println("C"); else { System.out.println("D");

55 if { if 1 { 2 if(age >= 20) System.out.println(" "); if(age >= 20) { System.out.println(" "); { if(age >= 20) System.out.println(" "); System.out.println(" ");

56 switch break;

57 switch switch (score) { case 1: System.out.println(" break; case 2: System.out.println(" break; case 3: System.out.println(" "); break; case 4: System.out.println(" "); break; case 5: System.out.println(" "); break; default: System.out.println(" System.out.println("switch "

58 switch (2) switch (score) { case 1: case 2: System.out.println(" break; case 3: case 4: case 5: System.out.println(" "); break; default: System.out.println("

59 switch i 1,2,3,4,5 switch(i) { case 1: System.out.println("A"); case 2: break; case 3: System.out.println("B"); case 4: default: System.out.println("C");

60 3 int c; if(a > b) { c = a; else { c = b; int c = (a > b)? a : b;? 1 : 2 true false 2

61 3 = > 1000? : ;

62 c (a) (b) (c) int a = 5; int b = 3; int c = (a > b)? a : b; int a = 5; int b = 3; int c = (a > b * 2)? a + 1 : b - 3; int a = -5; int c = (a > 0)? a : -a;

63

64 age 13 age 65 age >= 13 && age < 65 age age < 13 age >= 65 age age >= 13 && age < 65 && age!=20

65 a + 10 > b * 5 (a + 10) > (b * 5) a > 10 && b < 3 (a > 10) && (b < 3) x && ( y z ) (x && y ) z

66 if( == &&!= ) {

67 a,b,c (a) a b b c (b) a b a c (c) a,b,c c (d) c>b>a (e) a c a b (f) a b 2 a b 3

68 3 for while do while

69 for for for( ; ; ){ true false for

70 for for(int i = 0; i < 5; i++) { System.out.println(" ")

71 for for int sum = 0; for(int i = 1; i <= 100; i++) { sum += i; System.out.println(i + " System.out.println(" " + sum );

72 x x 2-2x + 1

73 { class ForExample2 { public static void main(string[] args) { int sum = 0; for(int i = 1; i <= 100; i++) { sum += i; System.out.println(i + " "); System.out.println(" " + sum );

74 while while while( ){ 1. true false while 2.1. for

75 while int i = 0; while(i < 5) { System.out.println(" "); i++; // int i = 5; while(i > 0) { System.out.println(i); i--; //

76 do while do while do { while( ); true 1. false do while for while

77 do while int i = 0; do { System.out.println(" "); i++; while(i < 5); int i = 5; do { System.out.println(i); i--; while(i > 0);

78 break; int sum = 0; for(int i = 1; i <= 10; i++) { sum += i; System.out.println(i + " if(sum > 20) { System.out.println(" 20 break; System.out.println(" " + sum );

79 continue; int sum = 0; for(int i = 1; i <= 10; i++) { if(i % 2 == 0) { continue; sum += i; System.out.println(i + " System.out.println(" " + sum );

80 for(int a = 1; a <= 3; a++) { System.out.println("a = "+ a); // for(int b = 1; b <= 3; b++) { System.out.println("b = "+ b); // 3 9

81 1x1=1 2x1=2 3x1=3 4x1=4 5x1=5 6x1=6 7x1=7 8x1=8 9x1=9 1x2=2 2x2=4 3x2=6 4x2=8 5x2=10 6x2=12 7x2=14 8x2=16 9x2=18 1x3=3 2x3=6 3x3=9 4x3=12 5x3=15 6x3=18 7x3=21 8x3=24 9x3=27 1x4=4 2x4=8 3x4=12 4x4=16 5x4=20 6x4=24 7x4=28 8x4=32 9x4=36 1x5=5 2x5=10 3x5=15 4x5=20 5x5=25 6x5=30 7x5=35 8x5=40 9x5=45 1x6=6 2x6=12 3x6=18 4x6=24 5x6=30 6x6=36 7x6=42 8x6=48 9x6=54 1x7=7 2x7=14 3x7=21 4x7=28 5x7=35 6x7=42 7x7=49 8x7=56 9x7=63 1x8=8 2x8=16 3x8=24 4x8=32 5x8=40 6x8=48 7x8=56 8x8=64 9x8=72 1x9=9 2x9=18 3x9=27 4x9=36 5x9=45 6x9=54 7x9=63 8x9=72 9x9=81 class Example { public static void main(string args[]) { for(int i = 1; i <= 9; i++) { for(int j = 1; j <= 9; j++) { System.out.println(); //

82 1

83 1. int[] scores; 2. scores = new int[5]; 3. scores[0] = 50; scores[4] = 80; [] 0 ( - 1) 4. System.out.println(scores[2]);

84 int[] scores; scores = new int[5]; scores[0] = 50; scores[1] = 55; scores[2] = 70; scores[3] = 65; scores[4] = 80; for(int i = 0; i < 5; i++) { System.out.println(scores[i]);

85 int[] scores = {50, 55, 70, 65, 80; int n = scores.length;

86 :* 1:*** 2:***** 3:****** 4:***** 5:** class Example { public static void main(string args[]) { int[] counts = {1, 3, 5, 6, 5, 2;

87 int[][] scores = new int[3][5]; scores[0][0] = 50; scores[2][3] = 65;

88 4

89

90 class Java class

91 2 (x=2,y=5) (x= -1,y=3) (0,0) 1 (3,4) 5

92

93 2 ( x,y) class Point { int x; Point int y; Point x y int x y 2

94 class { class {

95 new Point(); Point p = new Point(); p.x = 10; p.y = 5; Point p = new Point();

96 Point x y Point p = new Point(); p.x = 10; x

97 class Point { int x; // x int y; // y Point class PointInstanceExample { public static void main(string[] args) { Point p1 = new Point(); p1.x = 10; p1.y = 5; Point p2 = new Point(); p2.x = 5; p2.y = 2; System.out.println("p1 x " + p1.x); System.out.println("p1 y " + p1.y); System.out.println("p2 x " + p2.x); System.out.println("p2 y " + p2.y);

98 Java int, double, boolean

99 Point p = new Point(); p Point

100 class Dog { String name; class Example { public static void main(string[] args) { Dog dog1 = new Dog(); dog1.name = "Taro"; Dog dog2 = new Dog(); dog2.name = "Pochi"; Dog dog3 = dog2; System.out.println(dog3.name); dog3.name = "Jiro"; System.out.println(dog2.name);

101 Point p1 = new Point(); Point p2 = new Point(); Point p3 = p2; p1.x = 0; p1.y = 0; p2.x = 5; p2.y = 10;

102 Point[] points = new Point[5]; points[0] = new Point(); points[1] = new Point(); points[2] = new Point(); points[3] = new Point(); points[4] = new Point();

103 null Point[] points = new Point[5]; points[0] = new Point(); points[1] = new Point(); points[2] = new Point();

104 null null Point p; p = null; null Point p = new Point(); if(p == null) { System.out.println("p null"); else { System.out.println("p null

105 5

106 Point x,y Point

107 class { // // void () {

108 class Point { int x; int y; // void printposition() { System.out.println(" (" + this.x + ", " + this.y + ") "); this Point p = new Point(); p.x = 10; p.y = 5; p.printposition();

109

110

111 void ( ) {

112 () Point class Point { int x; int y; // x y n void multiply(int n) { this.x *= n; this.y *= n; Point p = new Point(); p.x = 10; p.y = 5; p.multiply(2);

113 Point class Point { int x; int y; // x y dx dy void add(int dx, int dy) { this.x += dx; this.y += dy; Point p = new Point(); p.x = 10; p.y = 5; p.add(2,3);

114 ( ) { return ;

115 return 1 Point class Point { Point p = new Point(); int x; p.x = 10; int y; p.y = 5; // x y int getxy() { return this.x*this.y; int xy = p.getxy();

116 Point class Point { int x; int y; boolean issameposition(point p) { if(this.x == p.x && this.y == p.y) { return true; else { return false; Point p1 = new Point(); p1.x = 10; p1.y = 5; Point p2 = new Point(); p2.x = 10; p2.y = 10; if(p1.issameposition(p2)){ System.out.println(" "); else { System.out.println(" ");

117 void () { void ( ) { ( ) { return ;

118 if(this.x == p.x && this.y == p.y) { return true; else { return false; return (this.x == p.x && this.y == p.y); if(p1.issameposition(p2) == true) { if(p1.issameposition(p2)) {

119 ( ) {

120 Point class Point { int x; int y; Point p = new Point(5, 10); // System.out.println(p.x); Point(int x, int y) { System.out.println(p.y); this.x = x; this.y = y;

121 class Rectangle { double width; // double height; // 1.Rectangle getarea Rectangle true false

122 6

123

124 2 class Point { int x; int y; void set(int x, int y) { this.x = x; this.y = y; Point p1 = new Point(); p1.set(10, 0); Point p2 = new Point(); p2.set(p1); void set(point p) { this.x = p.x; this.y = p.y;

125 class Point { int x; int y; Point() { this.x = 0; this.y = 0; Point(Point p) { this.x = p.x; this.y = p.y; Point p1 = new Point(); Point p2 = new Point(10, 20); Point p3 = new Point(p2); Point(int x, int y) { this.x = x; this.y = y;

126 this this. this. ( ) this( )

127 this class Point { int x; int y; this.x = x; this.y = y; this void set(int x, int y) { void set(point p) { this.x = p.x; this.y = p.y;

128

129 Point counter int class Point { static int counter = 0; int x; int y;

130 class Point { static int counter = 0; int x; int y;

131 class Point { static int counter = 0; int x; int y; Point(int x, int y) { this.x = x; this.y = y; Point.counter++; System.out.println( Point.counter); Point p1 = new Point(0, 0); Point p2 = new Point(5, 0); Point p3 = new Point(10, 5); System.out.println( Point.counter);. 1

132 class Point { this int x; int y; static int counter = 0; Point(int x, int y) { this.x = x; this.y = y; Point.counter++;

133 . static

134 class SimpleCalc { // static double gettrianglearea(double base, double height) { return base * height / 2.0; System.out.println(" SimpleCalc.getTriangleArea(10, 5) + " ");

135 class {

136 Java [ (1) ] [ [ (1) ] [ (3) ] new [ (3) ] int double [ (5) ] [ (4) ] [ (6) ] [ (6) ] ] (a) (b) (c) (d) (e) (f) (g)null (h) (i)

137 7

138

139 Java A B A B A B B A B A B A

140 Java Object

141

142 extends class A { A class B extends A { B A extends A

143 Object Object extends Object class A extends Object { A class B extends A {

144 class Point { int x; int y; void printinfo() { System.out.println(x); System.out.println(y); class ColorPoint extends Point { String color; ColorPoint cp = new ColorPoint(); cp.x = 5; cp.y = 10; cp.color = " ";

145 class Point { int x; int y; void printinfo() { // class ColorPoint extends Point { String color; void printinfo() { // ColorPoint cp = new ColorPoint(); cp.printinfo();

146

147 (1) A B B (2) (3) (4)

148 super. ( ); class Point { int x; int y; void printinfo() { // class ColorPoint extends Point { String color; void printinfo() { super.printinfo();

149 super( );

150 class B extends A { class B extends A { B() { super();

151 class B extends A { B() { abc(); B(int i) { def(); class B extends A { B() {super();abc(); B(int i) {super(); def();

152 class X { X() { System.out.println("[X]"); void a() { System.out.println("[x.a]"); void b() { System.out.println("[x.b]"); class Y extends X { Y() { System.out.println("[Y]"); void a() { System.out.println("[y.a]"); X,Y X x = new X(); x.a(); x.b(); Y y = new Y(); y.a(); y.b();

153 class X { X() { System.out.println("[X()]"); X(int i) { System.out.println("[X(int i)]"); class Y extends X { Y() { System.out.println("[Y()]"); Y(int i) { System.out.println("[Y(int i)]"); class Z extends Y { X,Y Y y0 = new Y(); Y y1 = new Y(10); Z z = new Z();

154 Point p = new Point(); ColorPoint cp = new ColorPoint(); Point ColorPoint Point cp = new ColorPoint();

155

156 class Person { void work() { // " " Person[] persons = new Person[3]; persons[0] = new Person(); class Student extends Person { persons[1] = new Student(); void work() { persons[2] = new Teacher(); // " " class Teacher extends Person { void work() { // " " void maketest() { for(int i = 0; i < 3; i++) { persons[i].work();

157 // 3 void workthreetimes(person p) { p.work(); p.work(); p.work(); Person new Teacher(), new Student()

158 A,B,C class A { class B extends A { class C { (1) A a = new A(); (2) A a = new B(); (3) A a = new C(); (4) B b = new A(); (5) B b = new B(); (6) B b = new C();

159 Person p = new Teacher(); Teacher t = (Teacher)p; t.maketest(); Person p = new Teacher(); ((Teacher)p).makeTest();

160

161 private private

162 private class Car { private int speed; // (Km/h) // speed 1 public void speedup() { if(speed < 80) { speed++; // speed 1 0 public void speeddown() { if(speed > 0) { speed--;

163 class Example { private int valuea; private int valueb; public int getvaluea() { return valuea; public void setvaluea(int a) { valuea = a; public int getvalueb() { return valueb; public void setvaluea(int b) { valueb = b;

164 final

165 public final static double PI = ; public final static int ADULT_AGE = 20; if(age == 20) { if(age == ADULT_AGE) {

166 static static int counter = 0; static double getsum(int x, int y) { return x + y; public static void main(string args[]) {

167 8

168 abstract abstract class Shape { Shape Shape s = new Shape();

169

170 abstract abstract class Shape { abstract void draw();

171 abstract class Shape { abstract void draw(); class Polyline extends Shape { void draw() { // class Rectangle extends Shape { void draw() { // class Circle extends Shape { void draw() { // Shape[] shapes = new Shape[3]; shapes[0] = new Polyline(); shapes[1] = new Rectangle(); shapes[2] = new Circle(); for(int i = 0; i < 3; i++) { shapes[i].draw();

172 Java 1

173

174

175 interface { interface HasGetAreaMethod { double getarea(); class implements {

176 interface HasGetAreaMethod { double getarea(); class Rectangle implements HasGetAreaMethod { double getarea() { return width*height; class Circle implements HasGetAreaMethod { double getarea() { return r*r*3.14; HasGetAreaMethod r = new Rectangle(); HasGetAreaMethod c = new Circle();

177 interface I { abstract class A { class B extends A { class C implements I { 1. A a = new A(); 2. B b = new B(); 3. C c = new C(); 4. I i = new I(); 5. A b = new B(); 6. B a = new A(); 7. I b = new B(); 8. I c = new C();

Java学習教材

Java学習教材 Java 学習教材 筑波大学コンピュータサイエンス専攻三谷純最終更新日 2017/3/15 (C) 2017 Jun Mitani 図表出典 : 三谷純著 プログラミング学習シリーズ Java ( 翔泳社刊 ) 本資料の位置づけ 本資料は Java 入門編ゼロからはじめるプログラミング ( 三谷純著 ) Java 入門編ゼロからはじめるプログラミング を専門学校 大学 企業などで教科書として採用された教員

More information

Javaプログラムの実行手順

Javaプログラムの実行手順 戻り値のあるメソッド メソッドには 処理に使用する値を引数として渡すことができました 呼び出し 側からメソッドに値を渡すだけでなく 逆にメソッドで処理を行った結果の値を 呼び出し側で受け取ることもできます メソッドから戻してもらう値のことを もどりち戻り値といいます ( 図 5-4) 図 5-4. 戻り値を返すメソッドのイメージ 戻り値を受け取ることによって ある計算を行った結果や 処理に成功したか失

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

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

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

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

やさしい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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

More information

r3.dvi

r3.dvi 00 3 2000.6.10 0 Java ( 7 1 7 1 GSSM 1? 1 1.1 4 4a 4b / / 0 255 HTML X 0 255 16 (0,32,255 #0020FF Java xclock -bg #0020FF xclock ^C (Control C xclock 4c 1 import java.applet.applet; import java.awt.*;

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

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

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

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プログラミングⅠ

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

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

2

2 問題 1 次の設問 1~5 に答えよ 設問 1. Java のソースプログラムをコンパイルするコマンドはどれか a) java b) javac c) javadoc d) jdb 設問 2. Java のバイトコード ( コンパイル結果 ) を実行するコマンドはどれか a) java b) javac c) javadoc d) jdb 設問 3. Java のソースプログラムの拡張子はどれか a).c

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

2

2 2014/01/15 プログラミング応用 b H24 年度期末テスト問題 問題 1 次の設問 1,2 に答えよ 設問 1 1 から 10 まで数えながら その数が偶数か奇数かを表示する JAVA プログラムの一部である 空欄に入るべき文字列は何か for( int i=1; 1 ; i++){ System.out.print(i); if( 2 == 0){ System.out.println("

More information

(Basic Theory of Information Processing) 1

(Basic Theory of Information Processing) 1 (Basic Theory of Information Processing) 1 10 (p.178) Java a[0] = 1; 1 a[4] = 7; i = 2; j = 8; a[i] = j; b[0][0] = 1; 2 b[2][3] = 10; b[i][j] = a[2] * 3; x = a[2]; a[2] = b[i][3] * x; 2 public class Array0

More information

2

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

More information

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

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

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

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

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

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

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

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プログラミングⅠ

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

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

JavaプログラミングⅠ

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

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 第 6 回 Switch 文 プロジェクトの持ち運び 授業開始前に ログオン後 不要なファイルを削除し て待機してください Java 1 第 6 回 2 前回のテーマ while 文を用いた繰り返し実行 for 文との使い分け 複雑な条件判定 && かつ または を使って Java 1 第 6 回 3 復習 : while 文はfor 文から 初期化式 を外に出し ステップを進める式

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

r6.dvi

r6.dvi I 2005 6 2005.11.18 1 1.1 2 Hello, World public class r5ex2 extends JApplet { Font fn = new Font("Helvetica", Font.BOLD, 24); g2.setfont(fn); for(int i = 0; i < 10; ++i) { g2.setpaint(new Color(100+i*5,

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

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

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

JavaScript 1.! DOM Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2

JavaScript 1.! DOM Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2 JavaScript (2) 1 JavaScript 1.! 1. 2. 3. DOM 4. 2. 3. Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2 (1) var a; a = 8; a = 3 + 4; a = 8 3; a = 8 * 2; a = 8 / 2; a = 8 % 3; 1 a++; ++a; (++

More information

10/8 Finder,, 1 1. Finder MAC OS X 2. ( ) MAC OS X Java ( ) 3. MAC OS X Java ( ) / 10

10/8 Finder,, 1 1. Finder MAC OS X 2. ( ) MAC OS X Java ( ) 3. MAC OS X Java ( ) / 10 10/8 2015-10-08 URL : http://webct.kyushu-u.ac.jp, 10/8 1 / 10 10/8 Finder,, 1 1. Finder MAC OS X 2. ( ) MAC OS X Java ( ) 3. MAC OS X Java ( ) 1. 30 2 / 10 10/8 Finder 1 Figure : : Apple.com 2, 3 / 10

More information

2 1 Web Java Android Java 1.2 6) Java Java 7) 6) Java Java (Swing, JavaFX) (JDBC) 7) OS 1.3 Java Java

2 1 Web Java Android Java 1.2 6) Java Java 7) 6) Java Java (Swing, JavaFX) (JDBC) 7) OS 1.3 Java Java 1 Java Java 1.1 Java 1) 2) 3) Java OS Java 1.3 4) Java Web Start Web / 5) Java C C++ Java JSP(Java Server Pages) 1) OS 2) 3) 4) Java Write Once, Run Anywhere 5) Java Web Java 2 1 Web Java Android Java

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

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

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

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

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

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

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

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

untitled

untitled Java 1 1 Java 1.1 Java 1.2 Java JavaScript 2 2.1 2.2 2.3 Java VM 3 3.1 3.2 3.3 3.4 4 Java 4.1 Java 4.2 if else 4.3 switch case 4.4 for 4.5 while 4.6 do-while 4.7 break, continue, return 4.8 try-catch-finally

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

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; 19 3!!...... (+) (>) (++) (+=) for while 3.1!! 3.1.1 50 20 20 5 (20, 20) 3.1.1 (1)(Blocks1.java) public class Blocks1 extends JApplet { public void paint(graphics g){ 5 g.drawrect( 20, 20, 50, 20); g.drawrect(

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

PowerPoint プレゼンテーション

PowerPoint プレゼンテーション 32786~32767 2147483648~2147483647 9223372036854775808~9223372036854775807 ±10 38 ~10 38 ±10 308 ~10 308 public static void main(string[] args) { int a; double b; String s; a = 42; b = 3.1415926535; s =

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

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

untitled

untitled 2011 7 21 (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 5 2 3 4 - 5 .. 6 - 7 public class KnapsackBB

More information

JavaプログラミングⅠ

JavaプログラミングⅠ Java プログラミング Ⅰ 12 回目クラス 今日の講義で学ぶ内容 クラスとは クラスの宣言と利用 クラスの応用 クラス クラスとは 異なる複数の型の変数を内部にもつ型です 直観的に表現すると int 型や double 型は 1 1 つの値を管理できます int 型の変数 配列型は 2 5 8 6 3 7 同じ型の複数の変数を管理できます 配列型の変数 ( 配列変数 ) クラスは double

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

5

5 5. 制御構造前章までのプログラムは, 基本的に実行文を上から順に実行していく単純な構造をしていた 実際のプログラムでは, 条件によって実行する文を変更したり, 同じ文を何回も実行したりと, 必ずしも上から順に実行するわけではない このような, プログラムの流れを決定するものを, プログラムの制御構造と呼ぶ 本章では, 制御構造に関係して以下を学習する 基本となる制御構造 順次実行 分岐実行 (if

More information

r2.dvi

r2.dvi 2 /Fitzz 2012.10.16 1 Reading 1.1 HCI bit ( ) HCI ( ) ( ) ( ) HCI ( ) HCI ( ) ^_^; 1 1.2,,!,, 2000 1.3 D. A.,,?,, 1990 1? 1 (interface) ( ) ( / ) (User Interface, UI) 2 :? import java.awt.*; import java.awt.event.*;

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

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

class TestPrimitiveType{ public static

class TestPrimitiveType{ public static プリミティブ型 ( 基本データ型 ) プリミティブ型 ( 基本データ型 ) 浮動小数点の数値範囲が正負対称でないのは, べき乗表示にバイアスがかかっているのと 0 以外すべて最上位 bit が 1 と決まっているので最上位を省略しているためである 分類 型 ビット数数値の範囲 符号付き整数 byte 8-2 7 ~+2 7-1(-128~+127) 符号付き整数 short 16-2 15 ~+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

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

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

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

2.2 Java C main Java main 2 C 6 C Java 3 C Java ( ) G101Hello.java G101Hello main G101Hello.java /* G101Hello */ class G101Hello { /* main */ public s

2.2 Java C main Java main 2 C 6 C Java 3 C Java ( ) G101Hello.java G101Hello main G101Hello.java /* G101Hello */ class G101Hello { /* main */ public s 2 2013 4 16 2.1............................... 2 1 2.2 Java......................... 2 2 2.3............. 2 2 2.4................................ 2 4 2.5............................ 2 5 2.6............................

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

ALG2012-F.ppt

ALG2012-F.ppt 2012 7 26 (sakai.keiichi@kochi-tech.ac.jp) http://www.info.kochi-tech.ac.jp/k1sakai/lecture/alg/2012/index.html 5 2 3 4 - 5 .. 6 - 7 public class KnapsackBB { // 0-1 private static double maxsofar; private

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

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

I. java.awt.rectangle java.lang.math random Java TM API java.awt Rectangle Rectangle (x,y)... public int x Rectangle X public int y Rectangle Y public

I. java.awt.rectangle java.lang.math random Java TM API java.awt Rectangle Rectangle (x,y)... public int x Rectangle X public int y Rectangle Y public 2018 08 03 10:30 12:00 I. IV III II. III. IV. ( a d) V. VI. 70 III 30 100 60 : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeylistener KE KeyEvent M MouseListener am addmouselistener

More information

cpp4.dvi

cpp4.dvi 2017 c 4 C++ (4) C++, 41, 42, 1, 43,, 44 45, 41 (inheritance),, C++,, 100, 50, PCMCIA,,,,,,,,, 42 1 421 ( ), car 1 [List 41] 1: class car { 2: private: 3: std::string m model; // 4: std::string m maker;

More information

Assignment_.java 0 Assignment_.java 課題 : 台形の面積 / class Assignment_ public static void main(string[] args) throws IOException キーボード準備 int top, bottom,

Assignment_.java 0 Assignment_.java 課題 : 台形の面積 / class Assignment_ public static void main(string[] args) throws IOException キーボード準備 int top, bottom, Assignment_.java Assignment_.java 課題 : 三角形の面積 / class Assignment_ public static void main(string[] args) throws IOException キーボード準備 0 int base, height; 三角形の底辺の長さと高さ double area; 面積 底辺の長さと高さの入力 System.out.println("

More information

Java演習(9) -- クラスとメソッド --

Java演習(9)   -- クラスとメソッド -- Java (9) Java (9) Java (9) 3 (x, y) x 1 30 10 (0, 50) 1 2 10 10 (width - 10, 80) -2 3 50 10 (width / 2, 110) 2 width 3 (RectMove4-1.java) import javax.swing.japplet; import javax.swing.timer; import java.awt.graphics;

More information

DVIOUT-exer

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

More information

コーディング基準.PDF

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

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

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I  Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~alse I Exercise on Programming I http://bit.ly/oitprog1 1, 2 of 14 ( RD S ) I 1, 2 of 14 1 / 44 Ruby Ruby ( RD S ) I 1, 2 of 14 2 / 44 7 5 9 2 9 3 3 2 6 5 1 3 2 5 6 4 7 8 4 5 2 7 9 6 4 7 1 3 ( RD S ) I 1, 2

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

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B 2 p.1 2 Java Java JDK Sun Microsystems JDK javac Java java JVM appletviewer IDESun Microsystems NetBeans, IBM 1 Eclipse 2 IDE GUI JDK Java 2.1 Hello World! 2.1.1 Java 2.1.1 Hello World Emacs Hello0.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