Unicode Unicode Integer.toHexString 16 Unicode System.out.println( " " + kan + " Unicode \\u" + Integer.toHexString( (int) kan ) ); Unicode u

Size: px
Start display at page:

Download "Unicode Unicode Integer.toHexString 16 Unicode System.out.println( " " + kan + " Unicode \\u" + Integer.toHexString( (int) kan ) ); Unicode u"

Transcription

1 Chpater 17. \ 'A' A ' ' '\n' Unicode \u '\u4e00' char char ; = ; w kan kan char w ; char kan = ' '; Unicode System.out.println (int) Casting public class Kan { public static void main( String [ ] args ) { char kan=' ' ; System.out.println( " " + kan + " Unicode " + (int)kan ); Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-1

2 Unicode Unicode Integer.toHexString 16 Unicode System.out.println( " " + kan + " Unicode \\u" + Integer.toHexString( (int) kan ) ); Unicode u6f22 Java Shift JIS Unicode (char) Casting Unicode 0 9 '0' < '1' < '2' < '3' < '4' < '5' < '6' < '7' < '8' <'9' A Z Unicode M N L ( char ) ( 'M' + 1 ) 'N' ( char ) ( 'M' - 1 ) 'L' if char c, w; // c int digit ; if ( c == 'A' c == 'a' ) { // c Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-2

3 System.out.print( "A "); if ( 'A' <= c && c <= 'Z' ) { w = (char) (c + 32); // c // w 10 '0' '5' '5' - '0' Unicode if ( '0' <= c && c <= '9' ) { digit = c - '0'; // c // 10 Java Unicode \u0020 \u public class GeneralScripts { public static void main( String [ ] args ) { for ( char code='\u0020' ; code < '\u8000' ; code++ ) { if ( code % 16 == 0 ) { System.out.print( "\n" + Integer.toHexString( (int) code ) ); System.out.print( " " + code ); Unicode \u4e00 \u4fff 1616 import java.awt.*; import java.applet.*; public class LocalScripts extends Applet { public void paint( Graphics gc ) { int base = 0x4e00; // for ( int code=base ; code < base + 0x1ff ; code++ ) { if ( code % 16 == 0 ) { gc.drawstring( Integer.toHexString( code ), 40, (code-base)/16 * ); gc.drawstring( ""+(char)code, code%16 * , (code base)/16 * ); Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-3

4 Mac OS X " \ Unicode 16 \u " \u4e00 \n" C Pascal Java String String String = String wow; String please = " "; wow = " " ; System.out.println( please ); Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-4

5 gc.drawstring( wow, 100, 20 ); String fickle = " " ; fickle = " " ; fickle = " " ; + String combined = " " + " " ; String complicated = " + ' ' " " + 4.5e3 + " " ; System.out.println( combined + complicated ); extended String extended = " "; extended = extended + " "; extended += " "; // " " // " " == > String String length length( ).length( ) length 17 lengthofmaki 17 maki.length( ) System.out.println Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-5

6 length 6 String maki= " "; int lengthofmaki = maki.length( ); System.out.println( " maki " + lengthofmaki ); System.out.println( " " + " ".length( ) ); ==!= Identification Equivalence String equals( ) equalsignorecase( ) endswith( ) startswith( ) true false plane if String plane = "F16 Falcon"; if ( plane.equals( "F16 Falcon" ) ) { System.out.println( "Air Force Fighter" ); else if ( plane.equals( "F18 Hornet" ) ) { System.out.println( "Navy Fighter" ); else { System.out.println( "Is this a plane of US?" ); equals equalsignorecase if String mytext = "Igor Stranvinsky"; if ( mytext.equalsignorecase( "IGOR STRAVINSKY" ) ) { System.out.println( mytext + " composed the Fire Bird." ); if playing? When if false true String message = "When did you stop eating?"; if ( message.endswith( "playing?" ) ) // false { System.out.println( "Oh, I used to think I would like to study anytime." ); Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-6

7 if ( message.startswith( "When" ) ) // true { System.out.println( "I used to stop everything before noon" ); == < >= compareto compareto( ) 0 String source = "This is a small message."; int result1 = source.compareto( "This" ); // int result2 = source.compareto( "No, it's long." ); // int result3 = source.compareto( "This is a small message." ); // 0 int result4 = source.compareto( "This is not a small message." ); // int result5 = source.compareto( "What is the message?" ); // if 0 String target = "Rabbit" ; if ( target.compareto( "Lion" ) > 0 ) { System.out.println( "Lion proceeds the target" ); if ( target.compareto( "Turtle" ) < 0 ) { System.out.println( "Turtle follows the target" ); substring.substring(, ).substring( ) 0 length( ) -1 0 length( ) 3 97 String message = "Sample Message"; System.out.println( message.substring( 3, 10 ) ); System.out.println( message.substring( 7 ) ); // "ple Mes" // "Message" 5 5 substring length String firstfive = message.substring( 0, 5 ); // "Sampl" String lastfive = message.substring( message.length( ) - 5 ); // "ssage" Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-7

8 0-1 charat.charat( ) 0 Srting crazycats = " "; char firstchar = crazycats.charat( 0 ); // ' ' char lastchar = crazycats.charat( crazycats.length( ) - 1 ); // ' ' charat substring substring charat String katochan = " " ; String fourth = katochan.substring( 3, 4 ); // " " char fourthchar = katochan.charat( 3 ); // ' ' charat String takostr = " "; for ( int i =0; i < takostr.length( ); i++ ) { System.out.println( i + " " + takostr.charat( i ) + " " ); wordcount wordcount wordcount String message = "This is a sample message"; int wordcount = 1; for ( int i=0; i < message.length( ); i++ ) { if ( message.charat( i ) == 32 ) { wordcount++; // System.out.println( message + " " + wordcount ); if 32Unicode 32 if ( message.charat( i ) == ' ' ) { wordcount++; Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-8

9 String substring + String original = " " ; String modified = original.substring( 0, 2 ) + ' ' + original.substring( 3 ); // " " String String StringBuffer String StringBuffer StringBuffer String StringBuffer StringBuffer buffer = "A sample message"; StringBuffer String StringBuffer String StringBuffer setcharat.setcharat(, ); 0-1 StringBuffer StringBuffer String String StringBuffer takostr = " "; takostr.setcharat( 0, ' ' ); System.out.println( takostr ); // " " indexof( ) -1 indexof(, ); Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-9

10 String message = " "; int search = message.indexof( ' ' ); // 0 int search2 = message.indexof( ' ', search+1 ); // 4 replace(, ) String message = " "; String mymessage = message.replace( ' ', ' ' ); // " " StringBuffer replace(,, ) String sentence = ""; sentence.replace( 3, 6, " "); // "" tolowercase( ) touppercase( ) String message= "This is a simple message"; System.out.println( message.tolowercase( ) ); System.out.println( message.touppercase( ) ); // "this is a simple message" // "THIS IS A SIMPLE MESSAGE" trim( ) String whitespace = " Snow in the north field. "; System.out.println( whitespace.trim( ) ); // "Snow in the north field" Wrapper Class tostring (new Integer(30)).toString( ) "30" (new Double(3.9)).toString( ) "3.9" (new Character( ' ' )).tostring( ) " " String valueof Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-10

11 String.valueOf( true ); // "true" String.valueOf( 12 ); // "12" String.valueOf( ); // "12.34" String.valueOf( 'A' ); // "A" "" valueof tostring "" + 30 " 30" Integer Integer.parseInt( ) "39" 39 int thirtynine = Integer.parseInt( "39" ); Java2 Double Double.parseDouble( ) "-12.3e4" double onetwothree = Double.parseDouble( "-12.3e4" ); Float.parseFloat Float.parseFloat( ) float fvalue = Float.parseFloat( "-12.3" ); JDK1.1 Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-11

12 int i = (new Integer( "45" )).intvalue( ); float f = (new Float( "34.5" )).floatvalue( ); double d = (new Double( "35.2e-3" )).doublevalue( ); "45" i "34.5"f "35.2e-3"d GUI Java Button TextField TextArea TextComponent new TextField( ) new TextArea(, ) settext gettext AWT 17-1 Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-12

13 init settext TextField tf = new TextField( 30 ) ; tf.settext( "Please input here." ); add( tf ); gettext( ) actionperformed String received = tf.gettext( ); tf.append( ": This is your input." ); paint import java.awt.*; import java.awt.event.*; import java.applet.*; public class TextInput extends Applet implements ActionListener { TextArea tarea; Button button; public void init( ) { tarea = new TextArea( 5, 40 ); button = new Button( "OK" ); button.addactionlistener( this ); add( tarea ); add( button ); public void actionperformed( ActionEvent e ) { String received = tarea.gettext( ); tarea.settext( " "+ received + " " ); repaint( ); 17-2 TextInput Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-13

14 TextField TextArea Return Enter actionperformed s, x, ch, shes y y ies s import import import java.awt.*; java.awt.event.*; java.applet.*; public class WordPlural extends Applet implements ActionListener { TextField singular, plural; public void init( ) { singular = new TextField( 20 ); plural = new TextField( 20 ); singular.addactionlistener( this ); add( singular ); add( plural ); public void actionperformed( ActionEvent e ) { String word = singular.gettext( ); if ( word.endswith( "s" ) word.endswith( "x" ) word.endswith( "ch" ) word.endswith( "sh" ) ) { plural.settext( word + "es" ); else if ( word.endswith( "y" ) ) { plural.settext( word.substring( 0, word.length( )-1 ) + "ies" ); else { plural.settext( word + "s" ); repaint( ); 17-3 WordPlural Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-14

15 String name = System.getProperty( "os.name" ); String lsep = System.getProperty( "line.separtor" ); Java Java tastream "39" 39 "23.45" int w = Integer.parseInt( "39" ); double d = (Double.parseDouble("23.45"); TextArea TextField Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-15

16 TextField tf = new TextField( 10 ); // init add( tf ); // Applet String line = tf.gettext(); // actionperformed init actionperformed import java.awt.*; import java.awt.event.*; import java.applet.*; public class NumberOperation extends Applet implements ActionListener { TextField operand1, operand2; // TextArea result; // Button kick; // public void init( ) { operand1 = new TextField( 10 ); operand2 = new TextField( 10 ); result = new TextArea( 7, 20 ); kick = new Button( "Operation" ); kick.addactionlistener( this ); add( operand1 ); add( operand2 ); add( kick ); add( result ); public void actionperformed( ActionEvent e ) { int op1 = Integer.parseInt( operand1.gettext() ); int op2 = Integer.parseInt( operand2.gettext() ); String lsep = System.getProperty( "line.separtor" ); result.settext( "sum " + (op1 + op2) + lsep + "difference " + (op1 - op2) + lsep + "product " + (op1 * op2) + lsep + "quotient " + (op1 / op2) + lsep + "remainder " + (op1 % op2) + lsep + "greater " + ((op1 > op2)? op1 : op2) ); repaint( ); Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-16

17 17-4 NumberOperation java.text import java.text.*; NumberFormat nf = NumberFormat.getNumberInstance( ); nf.setmaximumfractiondigits( 3 ); nf.setminimumintegerdigits( 7 ); nf.setgroupingused( false ); String message = nf.format( ); Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-17

18 Locale.CANADA Locale.CANADA_FRENCH Locale.CHINA Locale.CHINESE Locale.ENGLISH Locale.FRANCE Locale.FRENCH Locale.GERMAN Locale.GERMANY Locale.ITALIAN Locale.ITALY Locale.JAPAN Locale.JAPANESE Locale.KOREA Locale.KOREAN Locale.PRC Locale.SIMPLIFIED_CHINESE Locale.TAIWAN Locale.TRADITIONAL_CHINESE Locale.UK Locale.US DateFormat.DEFAULT DateFormat.FULL DateFormat.MEDIUM DateFormat.LONG DateFormat.SHORT import import java.text.*; java.util.*; DateFormat df = DateFormat.getDateInstance( DateFormat.DEFAULT, Locale.UK ); DateFormat tf = DateFormat.getTimeInstance( DateFormat.LONG, Locale.JAPAN ); String today = df.format( new Date( ) ); String now = tf.format( new Date( ) ); TextArea WordCounter if while wordcount Nengo Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-18

19 Copyright by Tatsuo Minohara 2004 Rev. D Dec. 16th Macintosh Java Primer Chapter 17-19

Local variable x y i paint public class Sample extends Applet { public void paint( Graphics gc ) { int x, y;... int i=10 ; while ( i < 100 ) {... i +=

Local variable x y i paint public class Sample extends Applet { public void paint( Graphics gc ) { int x, y;... int i=10 ; while ( i < 100 ) {... i += Safari AppletViewer Web HTML Netscape Web Web 13-1 Applet Web Applet init Web paint Web start Web HTML stop destroy update init Web paint start Web update Event Driven paint Signature Overwriting Overriding

More information

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

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 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 update Event Driven paint Signature Overwriting Overriding

More information

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

Chapter 20. [ ] ; [ ] = new [ ] ; Color colors [ ] = new Color[ 20 ]; // 20 Button operations [ ] = new Button[ 10 ]; // 10 colors[ 3 ] = new Color( 1 Chapter 20. [ ] ; [ ] = new [ ] ; Color colors [ ] = new Color[ 20 ]; // 20 Button operations [ ] = new Button[ 10 ]; // 10 colors[ 3 ] = new Color( 10, 30, 40 ); gc.setcolor( colors[ 3 ] ); operations[

More information

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

KeyListener init addkeylistener addactionlistener addkeylistener addkeylistener( this ); this.addkeylistener( this ); KeyListener public void keytyped KeyListener keypressed(keyevent e) keyreleased(keyevent e) keytyped(keyevent e) MouseListener mouseclicked(mouseevent e) mousepressed(mouseevent e) mousereleased(mouseevent e) mouseentered(mouseevent e)

More information

Chapter 19. init paint actionperformed init if Subroutine Function init paint ( ) { } ( ) void public void init( ) { } init void void public Copyright

Chapter 19. init paint actionperformed init if Subroutine Function init paint ( ) { } ( ) void public void init( ) { } init void void public Copyright Chapter 19. init paint actionperformed init if Subroutine Function init paint ( ) { ( ) void public void init( ) { init void void public Copyright by Tatsuo Minohara 2005 Rev. C 2005 Jan. 13th Macintosh

More information

try catch Exception Java try catch try { } catch ( Exception e ) { } e 16-1 try catch 0 try { int x = 0; int y = 10 / x; } catch ( Exception e ) { Sys

try catch Exception Java try catch try { } catch ( Exception e ) { } e 16-1 try catch 0 try { int x = 0; int y = 10 / x; } catch ( Exception e ) { Sys try catch Exception Java try catch catch ( Exception e ) { e 16-1 try catch 0 int x = 0; int y = 10 / x; catch ( Exception e ) { System.err.println( " " ); Copyright by Tatsuo Minohara 2004 Rev. C on Dec.

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

Color.cyan, Color.yellow, Color.pink, Color.orange, Color.white, Color.black, Color.gray, Color.darkGray, Color.lightGray ; Button barray [ ] = new Bu

Color.cyan, Color.yellow, Color.pink, Color.orange, Color.white, Color.black, Color.gray, Color.darkGray, Color.lightGray ; Button barray [ ] = new Bu Chapter 18. [ ] ; [ ] = new [ ] ; Color colors [ ] = new Color[ 20 ]; // 20 Button operations [ ] = new Button[ 10 ]; // 10 colors[ 3 ] = new Color( 10, 30, 40 ); g.setcolor( colors[ 3 ] ); operations[

More information

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

Chapter JDK KeyListener keypressed(keyevent e ) keyreleased(keyevent e ) keytyped(keyevent e ) MouseListener mouseclicked(mouseeven Chapter 11. 11.1. JDK1.1 11.2. KeyListener keypressed(keyevent e ) keyreleased(keyevent e ) keytyped(keyevent e ) MouseListener mouseclicked(mouseevent e ) mousepressed(mouseevent e ) mousereleased(mouseevent

More information

AWT setcolor, drawstring Java AWT Abstract Window Toolkit Graphics AWT import import java.awt.* ; // AWT Graphics import java.awt.graphics; // AWT Gra

AWT setcolor, drawstring Java AWT Abstract Window Toolkit Graphics AWT import import java.awt.* ; // AWT Graphics import java.awt.graphics; // AWT Gra AWT setcolor, drawstring Java AWT Abstract Window Toolkit Graphics AWT import // AWT Graphics import java.awt.graphics; // AWT Graphics paint g x y ( x, y ) drawline( x, y, x, y ) ; g.drawline( 20, 30,

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

AWT setcolor, drawstring Java AWT Abstract Window Toolkit Graphics AWT import import java.awt.* ; // AWT Graphics import java.awt.graphics; // AWT Gra

AWT setcolor, drawstring Java AWT Abstract Window Toolkit Graphics AWT import import java.awt.* ; // AWT Graphics import java.awt.graphics; // AWT Gra AWT setcolor, drawstring Java AWT Abstract Window Toolkit Graphics AWT import // AWT Graphics import java.awt.graphics; // AWT Graphics paint g x y ( x, y ) drawline( x, y, x, y ) ; g.drawline( 20, 30,

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

< F2D E E6A7464>

< F2D E E6A7464> ピタゴラス数 [Java アプレット ] [Java アプリケーション ] 1. はじめに 2 2 2 三平方の定理 a +b =c を満たす3つの自然数の組 ( a, b, c) をピタゴラス数と言います ピタゴラス数の最も簡単な例として (3,4,5) がありますね このピタゴラス数を求めるには ピタゴラスの方法とプラトンの方法の2つの方法があります 2 2 ピタゴラス数 (a,b,c) に対して

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

2

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

More information

< F2D82518CC282CC D2E6A7464>

< F2D82518CC282CC D2E6A7464> 2 個のさいころ 1. はじめに [Java アプレット ] [Java アプリケーション ] 2 個のさいころを同時に投げたときの目の出方を考えてみましょう この 2 個のさいころをそれぞれ さいころ Ⅰ さいころ Ⅱ とすると その目の出方は順に 1 1 2 1 3 1 4 1 5 1 6 1 1 2 2 2 3 2 4 2 5 2 6 2 1 3 2 3 3 3 4 3 5 3 6 3 1 4

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

< F2D B825082CC96E291E82E6A7464>

< F2D B825082CC96E291E82E6A7464> 3x+1 の問題 [Java アプレット ] [Java アプリケーション ] 1. はじめに どんな自然数から始めても良いので その数が偶数ならば2で割り 奇数ならば3 倍して1を加えることを繰り返します そうすると どんな自然数から始めても必ず1になるというのはほんとうなのでしょうか 例えば 11から始めると 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 となります

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

< F2D F B834E2E6A7464>

< F2D F B834E2E6A7464> ランダムウォーク [Java アプレット ] [Java アプレリケーョン ] 1. はじめに 酔っぱらいは前後左右見境なくふらつきます 酔っぱらいは目的地にたどり着こうと歩き回っているうちに何度も同じところに戻って来てしまったりするものです 今 酔っぱらいが数直線上の原点にいるとします 原点を出発して30 回ふらつくとき 30 回目に酔っぱらいがいる位置は 出発点である原点からどれくらい離れてしまっているのでしょうか

More information

< F2D825282CC947B909482CC A815B83682E6A>

< F2D825282CC947B909482CC A815B83682E6A> 3 の倍数のトランプカード 1. はじめに [Java アプレット ] [Java アプリケーション ] ここにトランプが 1 組あります ジョーカー 2 枚を除いて 52 枚を使います 3 の倍数は スペード クローバ ダイヤ ハートに それぞれ 3 と 6 と 9 と 12 の 4 枚ずつあるので 4 4=16 枚あります この 52 枚のトランプから 1 枚引いたとき そのカードが 3 の倍数である確率を考えます

More information

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C> 2 次関数のグラフの向きと広がり [Java アプレット ] [Java アプリケーション ] 1. はじめに 2 2 y=ax のグラフについて x の係数 aが正のときと負のときでは グラフにどのような違いがあるでしょうか 2 2 y=ax のグラフについて x の係数 aが正のとき 係数 aの値が大きくなるにつれて グラフの広がりはどうなるでしょうか 2 2 y=ax のグラフについて x の係数

More information

< F2D834F838C A815B A CC>

< F2D834F838C A815B A CC> グレゴリー ライプニッツの公式 [Java アプレット ] [Java アプリケーション ] 1. はじめに 次のグレゴリー ライプニッツの公式を用いて π の近似値を求めてみましょう [ グレゴリー ライプニッツの公式 ] π 4 =1-1 3 + 1 5-1 7 + 1 9-1 + 11 シミュレーションソフト グレゴリー ライプニッツの公式による π の近似 を使って π の近似値が求まる様子を観察してみてください

More information

Microsoft PowerPoint - prog12.ppt

Microsoft PowerPoint - prog12.ppt プログラミング言語 3 第 12 回 (2007 年 12 月 17 日 ) 1 今日の配布物 片面の用紙 1 枚 今日の課題が書かれています 本日の出欠を兼ねています 2/57 今日やること http://www.tnlab.ice.uec.ac.jp/~s-okubo/class/java06/ にアクセスすると 教材があります 2007 年 12 月 17 日分と書いてある部分が 本日の教材です

More information

< F2D B838A835882CC8CF68EAE2E6A7464>

< F2D B838A835882CC8CF68EAE2E6A7464> ウォーリスの公式 [Java アプレット ] [Java アプリケーション ] 1. はじめに 次のウォーリスの公式を用いて π の近似値を求めてみましょう [ ウォーリスの公式 ] π=2{ 2 2 4 4 6 6 1 3 3 5 5 7 シミュレーションソフト ウォーリスの公式による π の近似 を使って π の近似値が求まる様子を観察してみてください 2.Java アプレット (1) Javaプログラムリスト

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

橡告改.PDF

橡告改.PDF JAVA e 14 2 7 3 1-1 3 1-2 3 1-3 4 e 4 2-1 4 2-2 6 2-3 7 2-4 14 2-5 18 Java 19 3-1 Java 19 3-2 e 21 3-3 22 33 34 35 2 1-1 e 2000 American Society for Training Development e e e IT e e e 2003 e 5 2500 [1]

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

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

< F2D89BA8EE882C E6A7464>

< F2D89BA8EE882C E6A7464> 下手な鉄砲も数撃ちゃ当たる!! [Java アプレット ] [Java アプリケーション ] 1. はじめに 鉄砲を10 回撃つと1 回当たる腕前の人が鉄砲を撃ちます 下枠の [ 自動 10 回 ] または [ 自動 50 回 ] または [ 自動 100 回 ] をクリックすると それぞれ10 回 50 回 100 回 実験を繰り返します ただし 1 回の実験につき20 発の鉄砲を発射します シミュレーションソフト

More information

< F2D82B682E182F182AF82F12E6A7464>

< F2D82B682E182F182AF82F12E6A7464> 3 人のじゃんけん [Java アプレット ] [Java アプリケーション ] 1. はじめに A 君 B 君 C 君の 3 人でじゃんけんを 1 回するときの勝ち負けを考えてみましょう あいこの場合は A 君 B 君 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

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

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

< F2D92DE82E8914B82CC977088D32E6A7464>

< F2D92DE82E8914B82CC977088D32E6A7464> 釣り銭の用意の実験 [Java アプレット ] [Java アプリケーション ] 1. はじめに クラス会などの幹事を務めることはありませんか 幹事になったつもりで考えてみてください 仮に クラス会への参加者人数は 35 人で 会費は 3500 円であるとします また 参加者は 1000 円札 4 枚でお釣りを必要とする人と 1000 円札 3 枚と 500 円玉 1 個でお釣りの要らない人の 2

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

Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem

Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem Java Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem 2 MenuComponent MenuComponent setfont() void setfont(font f) MenuBar MenuBar MenuBar() MenuBar add() Menu add(menu m) Menu Menu Menu String

More information

< F2D8EA CE909482CC92EA82852E6A7464>

< F2D8EA CE909482CC92EA82852E6A7464> 自然対数の底 e [Java アプレット ] [Java アプリケーション ] 1. はじめに 対数は 17 世紀にネイピアやビュルギといった数学者たちが生み出した関数である 円周率 πと自然対数の底 eとは密接な関係があり どちらも無理数で超越数 ( 整数係数の代数方程式の解にならない実数 ) である 1737 年 オイラーは eが無理数であることを示した 1873 年 フランスの数学者エルミートは

More information

Microsoft PowerPoint - prog11.ppt

Microsoft PowerPoint - prog11.ppt プログラミング言語 3 第 11 回 (2007 年 12 月 10 日 ) 1 今日の配布物 片面の用紙 1 枚 今日の課題が書かれています 本日の出欠を兼ねています 2/57 1 今日やること http://www.tnlab.ice.uec.ac.jp/~s-okubo/class/java06/ にアクセスすると 教材があります 2007 年 12 月 10 日分と書いてある部分が 本日の教材です

More information

< F2D A839382CC906A2E6A7464>

< F2D A839382CC906A2E6A7464> ビュホンの針 1. はじめに [Java アプレット ] [Java アプリケーション ] ビュホン ( Buffon 1707-1788) は 針を投げて円周率 πを求めることを考えました 平面上に 幅 2aの間隔で 平行線を無数に引いておきます この平面上に長さ2bの針を落とすと この針が平行線と交わる確立 pは p=(2b) (aπ) 1 となります ただし b

More information

B02-095 2007 2 15 1 3 2 4 2.1............................. 4 2.2........................................ 5 2.3........................................ 6 3 7 3.1................................. 7 3.2..............................

More information

Microsoft PowerPoint - prog11.ppt

Microsoft PowerPoint - prog11.ppt プログラミング言語 3 第 11 回 (2007 年 12 月 10 日 ) 1 今日の配布物 片面の用紙 1 枚 今日の課題が書かれています 本日の出欠を兼ねています 2/57 今日やること http://www.tnlab.ice.uec.ac.jp/~s-okubo/class/java06/ にアクセスすると 教材があります 2007 年 12 月 10 日分と書いてある部分が 本日の教材です

More information

JavaプログラミングⅠ

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

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

< F2D BCA82CC978E89BA82CC8EC08CB12E6A7464>

< F2D BCA82CC978E89BA82CC8EC08CB12E6A7464> パチンコ玉の落下の実験 [Java アプレット ] [Java アプリケーション ] 1. はじめに 1 個のパチンコ玉が釘に当たって左右に分かれながら落下するとき パチンコ玉はどこに落下するのでしょうか ただし パチンコ玉が釘に当たって左右に分かれるとき その分かれ方は左右半々であるとします パチンコ玉が落下し易い場所はあるのでしょうか それとも どこの場所も同じなのでしょうか シミュレーションソフト

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

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

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

More information

public static void main(... ) { Copyright by Tatsuo Minohara 2004 rev. Oct. 6 Macintosh Java Primer Chapter 3-2

public static void main(... ) { Copyright by Tatsuo Minohara 2004 rev. Oct. 6 Macintosh Java Primer Chapter 3-2 System.out.print( "Once upon a time, " ); System.out.println( "a rabbit lived in the forest." ); System.out.println( "His name was Melo." ); Once upon a time, a rabbit lived in the forest. His name was

More information

< F2D A838B838D96402E6A7464>

< F2D A838B838D96402E6A7464> モンテカルロ法 [Java アプレット ] [Java アプリケーション ] 1. はじめに 一辺の長さが 2 の正方形とそれに内接する半径 1 の円が紙に書かれています この紙の上からたくさんのゴマをばらまきます 正方形の中に入ったゴマの数と そのうちで円の中に入ったゴマの数も数えます さあ このゴマの数からどうやって円周率 π を求めるのでしょうか 一辺の長さ2の正方形の面積は4で

More information

アプレットの作成

アプレットの作成 - 1 - import java.applet.applet; import java.awt.graphics; public class HelloWorld extends Applet { public void init() { resize(150,60) ; public void paint ( Graphics g ) { g.drawstring("hello, world!",

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

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

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

B 10 : N ip2003f10.tex B : 9/12/ :02 p.1/71

B 10 : N ip2003f10.tex B : 9/12/ :02 p.1/71 B 10 : ks91@sfc.wide.ad.jp N206 2003 ip2003f10.tex B : 9/12/2003 10:02 p.1/71 : / ip2003f10.tex B : 9/12/2003 10:02 p.2/71 ip2003f10.tex B : 9/12/2003 10:02 p.3/71 1 http://java.sun.com/j2se/1.4.1/docs/api/

More information

text_12.dvi

text_12.dvi C 12 2000 7 2 12 Java(7) { Swing(, ), 1 12.1 12 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 12.2 Swing : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

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

< F2D82518E9F8AD CC95BD8D7388DA93AE2E6A7464>

< F2D82518E9F8AD CC95BD8D7388DA93AE2E6A7464> 2 次関数のグラフの平行移動 [Java アプレット ] [Java アプリケーション ] 1. はじめに 2 2 y=ax のグラフとy=a(x-b) +c のグラフは 位置は違うけれど 形も広がりも全く同じです 2 2 y=a(x-b) +c のグラフは y=ax のグラフをx 軸方向に ( 右方向に ) +b y 軸方向に ( 上方向に ) +c だけ平行移動したものです 2 シミュレーションソフト

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

r4.dvi

r4.dvi 00 4 2000.6.24 0 GUI GUI GUI GUI 1 1.1 3 2 1 import java.applet.applet; import java.awt.*; public class r3ex2 extends Applet { Figure[] figs = new Figure[]{ new Circle(Color.blue, 100.0, 100.0, 30.0, 1.1,

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

text_13.dvi

text_13.dvi C 13 2000 7 9 13 Java(8) { Swing(2)(, ) 1 13.1 13 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 13.2 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

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

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

JavaプログラミングⅠ

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

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

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

( ) p.1 x y y = ( x ) 1 γ γ = filtergamma.java import java.applet.*; public class filtergamma extends Applet{ Image img; Image new_img; publi e001d 00 1 1 ( ) Figure 1: 1 shikaku.java import java.applet.*; public class shikaku extends Applet{ public void paint( Graphics g) { g.drawrect(,,0,0 ); // x(,) width = 0,height=0 g.drawrect(,,0,0 );

More information

Applet java.lang.object java.awt.component java.awt.container java.awt.panel java.applet.applet

Applet java.lang.object java.awt.component java.awt.container java.awt.panel java.applet.applet 13 Java 13.9 Applet 13.10 AppletContext 13.11 Applet java.lang.object java.awt.component java.awt.container java.awt.panel java.applet.applet Applet (1/2) Component GUI etc Container Applet (2/2) Panel

More information

Java言語 第1回

Java言語 第1回 Java 言語 第 8 回ウインドウ部品を用いる (1) 知的情報システム工学科 久保川淳司 kubokawa@me.it-hiroshima.ac.jp 前回の課題 (1) マウスを使って, 前回課題で作成した 6 4 のマスの図形で, \ をマウスクリックによって代わるようにしなさい 前回の課題 (2) import java.applet.applet; import java.awt.*;

More information

PowerPoint Presentation

PowerPoint Presentation 上級プログラミング 2( 第 3 回 ) 工学部情報工学科 木村昌臣 今日のテーマ GUI プログラミング入門 AWT Java で GUI を作る方法 (API) AWT Abstract Window Toolkit GUIをつくるクラス群を提供 ( 基本!) OSによらない外観 Swing 逆にいえば OS ネイティブな look and feel ではない AWT をもとに JavaFX JDK1.8

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

ex01.dvi

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

More information

解きながら学ぶJava入門編

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

More information

Java言語 第1回

Java言語 第1回 Java 言語 第 10 回ウインドウ型アプリケーション (1) 知的情報システム工学科 久保川淳司 kubokawa@me.it-hiroshima.ac.jp 前回の課題 (1) ボーダーレイアウト, グリッドレイアウト, パネルを使用して, 電卓風のボタンを実現する BorderLayout で NORTH, CENTER, SOUTH に分割 NORTHにはテキストフィールドを設定 CENTERにはパネルを使って9つのボタンを設定

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

ex01.dvi

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

More information

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

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 2018 06 08 11:00 12:00 I. I III II. III. IV. ( a d) V. VI. 80 40 40 100 60 : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeylistener KE KeyEvent M MouseListener am addmouselistener

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

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

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

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

MacOSXLambdaJava.aw

MacOSXLambdaJava.aw Living with Mac OS X in Lambda 21 2005 Copyright by Tatsuo Minohara Programming with Mac OS X in Lambda 21 - page 1 2005 Copyright by Tatsuo Minohara Programming with Mac OS X in Lambda 21 - page 2 2005

More information

2004 Copyright by Tatsuo Minohara Programming with Mac OS X in Lambda 21 - page 2

2004 Copyright by Tatsuo Minohara Programming with Mac OS X in Lambda 21 - page 2 Living with Mac OS X in Lambda 21 2004 Copyright by Tatsuo Minohara Programming with Mac OS X in Lambda 21 - page 1 2004 Copyright by Tatsuo Minohara Programming with Mac OS X in Lambda 21 - page 2 2004

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

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

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 II Java 09 2 13 10: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 KeyListener J JApplet L addmouselistener M MouseListener

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

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

ただし 無作為にスレッドを複数実行すると 結果不正やデッドロックが起きる可能性がある 複数のスレッド ( マルチスレッド ) を安全に実行する ( スレッドセーフにする ) ためには 同期処理を用いるこ とが必要になる 同期処理は 予約語 synchronized で行うことができる ここでは sy

ただし 無作為にスレッドを複数実行すると 結果不正やデッドロックが起きる可能性がある 複数のスレッド ( マルチスレッド ) を安全に実行する ( スレッドセーフにする ) ためには 同期処理を用いるこ とが必要になる 同期処理は 予約語 synchronized で行うことができる ここでは sy オブジェクト指向プログラミング演習 2010/10/27 演習課題 スレッド ( その 2) 同期処理 結果不正 デッドロック 前回のスレッドの演習では 複数のスレッドを実行し 一つのプログラムの中の違う処理を同時に実行し た ただし 無作為にスレッドを複数実行すると 結果不正やデッドロックが起きる可能性がある 複数のスレッド ( マルチスレッド ) を安全に実行する ( スレッドセーフにする )

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

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

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

15 Java 15.5 15.6 15.7 Checkbox() Checkbox(String str) Checkbox(String str, boolean state) Checkbox(String str, boolean state, CheckboxGroup grp) Checkbox(String str, CheckboxGroup grp, boolean state)

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

/ ( ) 8/7/2003 13:21 p.2/64

/ ( ) 8/7/2003 13:21 p.2/64 B 12 I ks91@sfc.wide.ad.jp N208 8/7/2003 13:21 p.1/64 / ( ) 8/7/2003 13:21 p.2/64 8/7/2003 13:21 p.3/64 2! 12 7/ 8 1 13 7/15 2 / ( ) 11 (SFC ) ( 5 ) 8/7/2003 13:21 p.4/64 10 2003/7/22 23:59 JST 11 ( )

More information

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

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

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