r3.dvi

Similar documents
r4.dvi

r14.dvi

r2.dvi

r14.dvi

r3.dvi

r2.dvi

I. (i) Foo public (A). javac Foo.java java Foo.class (C). javac Foo java Foo (ii)? (B). javac Foo.java java Foo (D). javac Foo java Foo.class (A). Jav

r4.dvi

r6.dvi

Chapter JDK KeyListener keypressed(keyevent e ) keyreleased(keyevent e ) keytyped(keyevent e ) MouseListener mouseclicked(mouseeven

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

KeyListener init addkeylistener addactionlistener addkeylistener addkeylistener( this ); this.addkeylistener( this ); KeyListener public void keytyped

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

: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

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

r4.dvi

untitled

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

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

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

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

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

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

Java学習教材

10K pdf

新・明解Java入門

r5.dvi

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

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;

II Java :30 12:00 I. I IV II. III. IV. ( a d) V. : this==null, T == N A ActionListener C class D actionperformed G getsource I implements K

Microsoft PowerPoint prog1_doc2x.pptx

K227 Java 2

Thread

PowerPoint Presentation

Java 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 2.

以下に java.awt.graphics クラスの主なメソッドを示す (Graphics クラスの ) メソッド drawline(int x1, int y1, int x2, int y2) drawrect(int x, int y, int width, int height) fillr

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

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

次の演習課題(1),(2)のプログラムを完成させよ

問1

ソフトウェア開発方法論2

Microsoft PowerPoint prog1_doc2.pptx

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

r8.dvi

手書認識 グラフ描画 Step2-2 手書認識 : 認識結果を PaintPanel で描画する < 属性付き文字列 AttributedString> 標準出力では分かりにくいうえに認識結果を使えないので 認識するごとに PaintPanel に文字を描画することにする ここで 数式はただの文字列

アプレットの作成

解きながら学ぶJava入門編

: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

Assignment_.java /////////////////////////////////////////////////////////////////////// // 課題 星の画像がマウスカーソルを追従するコードを作成しなさい 次 ///////////////////

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

I java A

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

LMNtal LMNtal LMNtal JAVA JAVA JAVA LMNtal LMNtal LMNtal


: : : TSTank 2

Java 2 - Lesson01

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

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

Chapter 20. [ ] ; [ ] = new [ ] ; Color colors [ ] = new Color[ 20 ]; // 20 Button operations [ ] = new Button[ 10 ]; // 10 colors[ 3 ] = new Color( 1

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

: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

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

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

text_13.dvi

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

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

I. (i) Java? (A). Foo_Bar (B). G day (C). 999 (D). Golgo13 (ii)? (A). Java public (B). Java (C). Java JavaScript (D). Java C Java C (iii)? (A). Java (

ガイダンス

Microsoft PowerPoint - prog10.ppt

vol.30.}...`.X...b.h

Animals サンプル Step3 張り付けた動物の上をクリックすると それぞれの鳴き声で鳴く その鳴く間 一定時間 ( ここでは 1 秒間 ) 画像が別のものに変わる <アニメーションの基礎 : タイマーについて> アニメーションは アプリケーションが指定する間 一定間隔でどんどん画像をおきかえ

Microsoft PowerPoint - OOP.pptx

2008 e-learning T050050

Microsoft PowerPoint - prog10.ppt

ガイダンス

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

: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

r1.dvi

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

4 p.2 4 GUI return; public void mousepressed(mouseevent e) { /* 5 */ public void mousereleased(mouseevent e) { /* 5 */ public void mouseentered(mousee

( ) p.1 x y y = ( x ) 1 γ γ = filtergamma.java import java.applet.*; public class filtergamma extends Applet{ Image img; Image new_img; publi

JavaプログラミングⅠ

Graphical User Interface 描画する

text_08.dvi


Microsoft PowerPoint - swing3.ppt

r02.dvi

ohp02.dvi

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

GUIプログラムⅣ

Animals サンプル Step 1 動物の種類を指定しておいて クリックした場所に画像を貼り付ける < レイアウトについて > 前回は ラベルやボタンの位置を座標で設定した Absolute Layout を選んだためである レイアウトは どのようにボタンなどのコンポーネントを配置するかを決定す

ÿþ˜u#u·0¹0Æ0à0

Microsoft PowerPoint - swing2.ppt

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

課題

Java講座

Java言語 第1回

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

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

Safari AppletViewer Web HTML Netscape Web Web 15-1 Applet Web Applet init Web paint Web start Web HTML stop destroy update init Web paint start Web up

Transcription:

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)); g.filloval(100, 50, 100, 100); public static void main(string[] args) { JFrame app = new JFrame(); app.add(new Sample21()); app.setsize(400, 300); app.setdefaultcloseoperation(jframe.exit_on_close); app.setvisible(true); main() JPanel paintcomponent() paintcomponent() Sample21 JPanel import java.awt.*; import javax.swing.*; public class Sample21b { public static void main(string[] args) { JFrame app = new JFrame(); app.add(new MyPanel()); app.setsize(400, 300); app.setdefaultcloseoperation(jframe.exit_on_close); app.setvisible(true); class MyPanel extends JPanel { public void paintcomponent(graphics g) { g.setcolor(new Color(255, 180, 99)); g.filloval(100, 50, 100, 100); 1 Java 2

(1) 1 (2) (3) 2) 1 2 2)new ( ) class Chlid extends Parent { new Parent() { new Chlid() 2: 3) import java.awt.*; import javax.swing.*; public class Sample21c { public static void main(string[] args) { JFrame app = new JFrame(); app.add(new JPanel() { // public void paintcomponent(graphics g) { g.setcolor(new Color(255, 180, 99)); g.filloval(100, 50, 100, 100); ); // app.add ); app.setsize(400, 300); app.setdefaultcloseoperation(jframe.exit_on_close); app.setvisible(true); 3) app.add( ) JPanel : ( 3

) ( 3) ( 4) ) 4) JFrame ( ) addmouselisner() addmouselistener() implements MouseListener click! void mouseclicked() { 3: 5) 5) 1 java.awt.event import MouseListener java.awt.event.*; mousepressed(mouseevent e) mousereleased(mouseevent e) mouseclicked(mouseevent e) mouseentered(mouseevent e) mouseexited(mouseevent e) MouseMotionListener mosusemoved(mouseevent e) mousedragged(mouseevent e) KeyListener keypressed(keyevent e) keyreleased(keyevent e) keytyped(keyevent e) 4

MouseListener 5 5 implements MouseListener ( mousepressed() ) MouseAdapter MouseMotionAdapter KeyAdapter + class MyAdapter1 extends MouseMotionListener { public void mousedragged(mouseevent e) { addmousemotionlistener(new MyAdapter1()); 5 + addmousemotionlistener(new MouseMotionAdapter() { public void mousedragged(mouseevent evt) { ); 2 6) 6) 1 interface Figure { public void draw(graphics g); public void moveto(int x, int y); public boolean hit(int x, int y); 5

implements Figure Figure f f.draw() f.hit() f.moveto() 4: draw() moveto() hit() XY XY 7) 7)? 4 Figure Figure Figure f f.draw() (polymorphism) 8) 8) X X Y Y Z 5-1: 2 ( 5) 9) 9) ( ) static static 5: 10) (Figure ) ArrayList<Figure> 10) 6

( ) 11) null import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; public class Sample51 extends JPanel { ArrayList<Figure> figs = new ArrayList<Figure>(); Figure sel = null; public Sample51() { setopaque(false); figs.add(new Circle(Color.PINK, 200, 100, 40)); figs.add(new Circle(Color.GREEN, 220, 80, 30)); figs.add(new Rect(Color.YELLOW, 240, 60, 30, 40)); figs.add(new Rect(Color.BLUE, 260, 40, 80, 40)); addmouselistener(new MouseAdapter() { public void mousepressed(mouseevent evt) { sel = pick(evt.getx(), evt.gety()); ); addmousemotionlistener(new MouseMotionAdapter() { public void mousedragged(mouseevent evt) { if(sel == null) { return; sel.moveto(evt.getx(), evt.gety()); repaint(); ); figs 2 2 2 sel ( pick() moveto() return private Figure pick(int x, int y) { Figure p = null; for(figure f: figs) { if(f.hit(x, y)) { p = f; 7

return p; public void paintcomponent(graphics g) { for(figure f: figs) { f.draw(g); public static void main(string[] args) { JFrame app = new JFrame(); app.add(new Sample51()); app.setsize(400, 300); app.setdefaultcloseoperation(jframe.exit_on_close); app.setvisible(true); 12) pick() 12) p private null figs 13) 13) hit() p for( : ) for foreach p null paintcomponent() figs draw() main() interface Figure { public void draw(graphics g); public boolean hit(int x, int y); public void moveto(int x, int y); static class Circle implements Figure { Color col; int xpos, ypos, rad; public Circle(Color c, int x, int y, int r) { col = c; xpos = x; ypos = y; rad = r; public boolean hit(int x, int y) { return (xpos-x)*(xpos-x) + (ypos-y)*(ypos-y) <= rad*rad; public void moveto(int x, int y) { xpos = x; ypos = y; public void draw(graphics g) { g.setcolor(col); g.filloval(xpos-rad, ypos-rad, rad*2, rad*2); static class Rect implements Figure { Color col; int xpos, ypos, width, height; public Rect(Color c, int x, int y, int w, int h) { 8

col = c; xpos = x; ypos = y; width = w; height = h; public boolean hit(int x, int y) { return xpos-width/2 <= x && x <= xpos+width/2 && ypos-height/2 <= y && y <= ypos+height/2; public void moveto(int x, int y) { xpos = x; ypos = y; public void draw(graphics g) { g.setcolor(col); g.fillrect(xpos-width/2, ypos-height/2, width, height); 14) hit() Figure Circle (x,y) 2 (= (x x 0) 2 + Rect Figure (y y 0) 2 ) 2 implements Figure 14) X Y 5-1 Sample51.java a. b. ( ) c. ( ) d. 15) 15) (x,y) 5-2-ab (x, y) (x 1, y 1) (x 2, y 2) (x 1, y 1) figs / / (x 2 x 1) (y y 1) (y 2 y 1) (x public void mousepressed(mouseevent evt) { x 1) / / ( sel = pick(evt.getx(), evt.gety()); (x 1, y 1) (x 2, y if(sel!= null) { 2) (x 1, y 1) (x, y) figs.remove(sel); figs.add(sel); repaint(); 2 sel 16) ) 9

else { Color c = Color.getHSBColor((float)Math.random(), 1f, 1f); sel = new Circle(c, evt.getx(), evt.gety(), 30); figs.add(sel); repaint(); 5-2-cd 16)Color.getHSBColor() HSB (Hue) (Saturaiton) (Blightness) draw() moveto() hit() 3 implements Figure 3 (0.0f 1.0f hit() float ) return false; moveto() ( ) figs Math.random() Math.random() figs.add(new Triangle(Color.RED, 200, 100, 280, 100, 220, 50)); double [0.0, 1.0) figs.add(new Triangle(Color.YELLOW, 220, 80, 290, 90, 220, 30)); float figs.add(new House(Color.BLUE, Color.GREEN, 20, 100, 120)); hit() ( )moveto() static class Triangle implements Figure { public boolean hit(int x, int y) { int a = (xs[1]-xs[0])*(y-ys[0]) - (ys[1]-ys[0])*(x-xs[0]); int b = (xs[2]-xs[1])*(y-ys[1]) - (ys[2]-ys[1])*(x-xs[1]); int c = (xs[0]-xs[2])*(y-ys[2]) - (ys[0]-ys[2])*(x-xs[2]); return a <= 0 && b <= 0 && c <= 0; public void moveto(int x, int y) { xs[1] += x-xs[0]; ys[1] += y-ys[0]; xs[2] += x-xs[0]; ys[2] += y-ys[0]; xs[0] = x; ys[0] = y; hit() 3 17) 17) moveto() XY 2 3 XY 18) += 1 18) moveto() hit() 3 19) 19) 10

static class House implements Figure { public boolean hit(int x, int y) { return r1.hit(x,y) r2.hit(x,y) t1.hit(x,y); 3 5-1 XY moveto() XY 1 SimpleFigure static abstract class SimpleFigure implements Figure { Color col; int xpos, ypos; public SimpleFigure(Color c, int x, int y) { col = c; xpos = x; ypos = y; public void moveto(int x, int y) { xpos = x; ypos = y; public abstract boolean hit(int x, int y); public abstract void draw(graphics g); XY moveto() abstract? 20) SimpleFigure Figure ( ) 11

(abctract class) abstract hit() moveto() Figure ( ) 20) (abstract method) 21) (concrete class) 21) 22) (hit() draw() static class Circle extends SimpleFigure { int rad; public Circle(Color c, int x, int y, int r) { super(c, x, y); rad = r; 22) static class Rect extends SimpleFigure { int width, height; public Rect(Color c, int x, int y, int w, int h) { super(c, x, y); width = w; height = h; 23) SimpleFigure col implements Figure xpos ypos moveto() 23)24) super? 24) rad ( SimpleFigure) width height XY SimpleFigure 25) col xpos ypos 25) super() JFrame super() Java JFrame super() super() 5-2 26) 26) 12

4 27) instanceof Figure f1 if if(f1 instanceof Circle) { Cicle c1 = (Cicle)f1; // OK 28) 27) 5-3: Graphics Graphics2D ( tic-tac-toe) setstroke() ( 5) Figure 28) Figure draw() 29) 29) 6: 13

interface Figure { public void draw(graphics g); static class Maru implements Figure { int xpos, ypos, sz; public Maru(int x, int y, int s) { xpos = x; ypos = y; sz = s; public void draw(graphics g) { g.setcolor(color.black); ((Graphics2D)g).setStroke(new BasicStroke(4)); g.drawoval(xpos-sz, ypos-sz, 2*sz, 2*sz); static class Batsu implements Figure { int xpos, ypos, sz; public Batsu(int x, int y, int s) { xpos = x; ypos = y; sz = s; public void draw(graphics g) { g.setcolor(color.black); ((Graphics2D)g).setStroke(new BasicStroke(4)); g.drawline(xpos-sz, ypos-sz, xpos+sz, ypos+sz); g.drawline(xpos-sz, ypos+sz, xpos+sz, ypos-sz); static class Rect implements Figure { Color col; int xpos, ypos, width, height; public Rect(Color c, int x, int y, int w, int h) { col = c; xpos = x; ypos = y; width = w; height = h; public boolean hit(int x, int y) { return xpos-width/2 <= x && x <= xpos+width/2 && ypos-height/2 <= y && y <= ypos+height/2; public int getx() { return xpos; public int gety() { return ypos; public void draw(graphics g) { g.setcolor(col); g.fillrect(xpos-width/2, ypos-height/2, width, height); figs 14

boolean turn 9 Batsu 1 figs 30) 30) / % import java.awt.*; i 0 1 2 3 4 5 6 import java.awt.event.*; 7 8 r 0 0 0 1 1 1 2 2 2 c import javax.swing.*; 0 1 2 0 1 2 0 1 2 import java.util.*; 1 for 9 public class Sample51 extends JPanel { ArrayList<Figure> figs = new ArrayList<Figure>(); boolean turn = true; public Sample51() { setopaque(false); for(int i = 0; i < 9; ++i) { int r = i / 3, c = i % 3; figs.add(new Rect(Color.PINK,80+r*60,40+c*60,56,56)); figs.add(new Batsu(300, 40, 24)); addmouselistener(new MouseAdapter() { public void mouseclicked(mouseevent evt) { Rect r = pick(evt.getx(), evt.gety()); if(r == null) { return; figs.remove(figs.size()-1); if(turn) { figs.add(new Batsu(r.getX(), r.gety(), 24)); figs.add(new Maru(300, 40, 24)); else { figs.add(new Maru(r.getX(), r.gety(), 24)); figs.add(new Batsu(300, 40, 24)); turn =!turn; repaint(); ); public Rect pick(int x, int y) { Rect r = null; for(figure f: figs) { if(f instanceof Rect && ((Rect)f).hit(x, y)) { r = (Rect)f; return r; public void paintcomponent(graphics g) { for(figure f: figs) { f.draw(g); 15

public static void main(string[] args) { JFrame app = new JFrame(); app.add(new Sample51()); app.setsize(400, 300); app.setdefaultcloseoperation(jframe.exit_on_close); app.setvisible(true); // Figure, Maru, Batsu, Rect pick() figs ( ) 31)! 31) true false false true pick 5-1 hit() Rect instanceof Rect OK hit() paintcomponent() main() 32) Graphics setfont() 5-1 Sample51.java setcolor() drawstring() a. 3 3 5 Font Font b. 3 new Font("Serif", c. 3 5 Font.BOLD, 20) 32) 33) API d. 16 16 33)5 33 ( N ) e. 34) 34) 16

5-1-abc 5 Graphics drawstring() setfont() XY Text static class Text implements Figure { int xpos, ypos; String txt; Font fn; public Text(int x, int y, String t, Font f) { xpos = x; ypos = y; txt = t; fn = f; public void settext(string t) { txt = t; public void draw(graphics g) { g.setcolor(color.black); g.setfont(fn); g.drawstring(txt, xpos, ypos); 5 2 Java 2 ( 7) board 10 16 2 int[][] board = new int[10][16]; int[][] new 2 2 board[0][0] board[0][1] board[0][15] board[1][0] board[1][1] board[1][15] board[9][0] board[9][1] board[9][15] 17

board: board[0][0] board[0][1] board[0][15] 0) 1) 2) 9) board[9][0] board[9][1] board[9][15] 7: 2 / / 3 0 1 2 static final int EMPTY = 0, BATSU = 1, MARU = 2; final 35) 35)36) 2 board EMPTY 37) EMPTY BATSU MARU 36) 5-3 figs turn board Text t1 winner Java EMPTY 37)Java 38) 0 EMPTY public class ex51abc extends JPanel { static final int EMPTY = 0, BATSU = 1, MARU = 2; static final int YMAX = 10, XMAX = 16; ArrayList<Figure> figs = new ArrayList<Figure>(); boolean turn = true; int winner = EMPTY; int[][] board = new int[ymax][xmax]; Text t1 = new Text(20, 20, " ", new Font("Serif", Font.BOLD, 22)); public ex51abc() { figs.add(t1); for(int i = 0; i < 160; ++i) { int r = i / YMAX, c = i % YMAX; figs.add(new Rect(Color.PINK, 80+r*20, 40+c*20, 18, 18)); 18

setopaque(false); addmouselistener(new MouseAdapter() { public void mouseclicked(mouseevent evt) { Rect r = pick(evt.getx(), evt.gety()); if(r == null winner!= EMPTY) { return; int x = (r.getx()-80)/20, y = (r.gety()-40)/20; if(board[y][x]!= EMPTY) { t1.settext(" "); repaint(); return; if(turn) { figs.add(new Batsu(r.getX(), r.gety(), 8)); board[y][x] = BATSU; else { figs.add(new Maru(r.getX(), r.gety(), 8)); board[y][x] = MARU; int s = board[y][x], a = ck(1,1,s), b = ck(1,-1,s); int c = ck(1,0,s), d = ck(0,1,s); if(a > 4 b > 4 c > 4 d > 4) { ); t1.settext((turn?" ":" ")+" "); winner = turn? BATSU : MARU; else { turn =!turn; t1.settext(" " + (turn?" ":" ")); repaint(); 38) javac -encoding JISAutoDetect board 5 ck() (MARU BATSU) ( ) 5 winner ck() c max private int ck(int dx, int dy, int s) { int max = 1; for(int y = 0; y < YMAX; ++y) { for(int x = 0; x < XMAX; ++x) { int c = 0; for(int k = 0; k < 5; ++k) { int x1 = x + dx*k, y1 = y + dy*k; if(y1 < 0 y1 >= YMAX x1 < 0 x1 >= XMAX board[y1][x1]!= s) { break; ++c; 19

max = Math.max(max, c); return max; 5 : Java ( ) 39) foreach 39) Java ( ) ArrayList java.util import java.util.*; ArrayList ArrayList <> Circle ArrayList<Circle> <> 40) 40)41) JDK 1.5 ArrayList<E> Java ( E 41)Java ) int double new ArrayList<E>() ( ) void add(e) Integer Double void set(int, E) E get(int) / void remove(int) void remove(object) int size() Iterator<E> iterator() Iterator<E> E iterator() foreach 20

42) int Integer int Integer / ArrayList<Integer> a = new ArrayList<Integer>(); a.add(1); a.add(2); a.add(3); // for(int i: a) { i // 42) Iterator<E> iterator() Iterable<E> foreach 21