text_08.dvi

Similar documents
10K pdf

text_10.dvi

Microsoft Word - keisankigairon.ch doc

K227 Java 2

Java学習教材

ALG2012-A.ppt

I java A

: : : TSTank 2

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

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

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

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

untitled

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

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

新・明解Java入門

r1.dvi

VB.NETコーディング標準

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

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

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

明解Java入門編

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

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


r07.dvi

ohp07.dvi

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

Microsoft PowerPoint - chap10_OOP.ppt

ex01.dvi

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

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

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

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

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

目 次 Java GUI 3 1 概要 クラス構成 ソースコード例 課題...7 i

cpp4.dvi

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

Java updated

226

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

ex01.dvi

JavaプログラミングⅠ

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


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;

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

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

8 if switch for while do while 2

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

JAVA入門

1.ppt

r02.dvi

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

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>

解きながら学ぶJava入門編

r3.dvi

JavaプログラミングⅠ

新・明解Java入門

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

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

JavaプログラミングⅠ

presen.gby

< F2D82518E9F8AD CC95BD8D7388DA93AE2E6A7464>

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

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

Transcription:

C 8 12 6 6

8 Java (3) 1 8.1 8 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 8.2 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 8.2.1 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 8.2.2 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 2 8.2.3 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 2 8.2.4 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 3 8.3 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 6 8.4 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 7 8.5 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 11 {i{

8 Java (3) 8.1 8 Java 8 8.2 8.2.1 class class \{" \" < > class { < > < > < > (modier) class abstract... abstract final public... final... public 1

8.2.2 < > <= > public... protected... private... int x public int y protected int r private double c Graphics gc public JFrame myframe // // // // // Graphics // myframe public static (class eld) 1 1 static int [] data = {9, 7, 6 public static double E=2.7182 // 8.2.3 (constructor) 1 2

Java 8.2.4 (method) C ( < > ( ) { return( ) return void void ( ) public, protected, private static (static method) (class method) static Java. ( ) Java (Overload) 3

// Rectangle.java public class Rectangle { protected double width, height // public Rectangle(double w, double h) { // 1 width = w height = h public Rectangle() { // 2 width = 3 height = 3 // double area() { // area() return width*height public double circumference() { // circumference() return 2*(width + height) public static void main(string [] args){ // main() Rectangle r1 = new Rectangle(10,5) System.out.println("Rectangle 1:") System.out.println("width is " + r1.width) System.out.println("height is " + r1.height) System.out.println("area is " + r1.area()) System.out.println("circumference is " + r1.circumference()) System.out.println("--------------------------") System.out.println("Rectangle 2:") Rectangle r2 = new Rectangle() System.out.println("width is " + r2.width) System.out.println("height is " + r2.height) System.out.println("area is " + r2.area()) System.out.println("circumference is " + r2.circumference()) double 2 2 Rectangle.java $ javac Recatngle.java $ java Rectangle Rectangle 1: width is 10.0 height is 5.0 area is 50.0 circumference is 30.0 -------------------------- Rectangle 2: width is 3.0 height is 3.0 area is 9.0 circumference is 12.0 4

8-1 (Circle) x,y r 1 main() (x=10, y=5, r=4) 1 x 7 y 10 Java x! 0! = 1 x! =x (x ; 1)! // Factorial.java class Factorial { public static void main(string [] args) { int n = 10 System.out.println("n = " + n) System.out.println("Factorial(" + n +")=" + fact(n)) public static int fact(int n) { // if (n==0) { return(1) else { return(n * fact(n-1)) Factorial.java $ javac Factorial.java $ java Factorial n = 10 Factorial(10)=3628800 fact(int n) 5

8.2 B 8 ) [1,6,15,12,7,9,23,2,10,4,20] 8.3 Java 1 new = new ( ) = new ( ) // MyObjects.java import java.util.date class MyObjects { public static void main(string [] args) { Date d d = new Date() System.out.println("Date : " + d) Rectangle r = new Rectangle(30,40) System.out.print("My rectangle is "+ r.width + "cm x ") System.out.print(r.height + "cm area=" + r.area() + "cm^2 ") System.out.println("circumference=" + r.circumference() + "cm") String firstname = new String("Ichiro") String lastname lastname = "Suzuki" System.out.println("Object Name : " + firstname + " " + lastname) MyObjects.java 6

$ javac MyObjects.java $ java MyObjects Now Date : Thu May 31 19:38:45 JST 2001 My rectangle is 30.0cm x 40.0cm area=1200.0cm^2 circumference=140.0cm Object Name : Ichiro Suzuki 8.4 6 1-(a) (Stack) ( 8.1) push/pop push 1 pop 1 capacityincrement capacity = 5 push(string) String pop() count = 2 "Nobu" "Kenji" itemlist = String[capacity] 8.1: 7

// Stack.java public class Stack { // private int count // private int capacity // private int capacityincrement // String [] itemlist // // public Stack() { count = 0 capacity = 5 capacityincrement = 2 itemlist = new String[capacity] // public Stack(String [] list) { count = list.length capacity = list.length capacityincrement = 5 itemlist = list // push public void push (String obj){ // // capacityincrement if (count == capacity) { capacity += capacityincrement String [] templist = new String[capacity] for (int i = 0 i < count i++){ templist[i]=itemlist[i] itemlist = templist // // count 1 itemlist[count] = obj count++ // pop public String pop (){ if (count == 0){ // return null //. else { // count-- // return itemlist[count] // // end pop() ( ) 8

// public void printitems(){ for (int i=0 i < count i++){ System.out.print(itemList[i] + ",") System.out.println(" ") // // Stack.java // StackTest.java public class StackTest { public static void main (String [] args) { String [] items = {"Kenji","Nobu" Stack mystack = new Stack(items) // mystack System.out.println("Initial data :") mystack.printitems() // mystack System.out.println(" ") System.out.println("-----------") mystack.push("taro") // System.out.println("Data after push Taro :") mystack.printitems() System.out.println(" ") System.out.println("-----------") String popobject1 = mystack.pop() // System.out.println("Data after pop object " + popobject1 + " :") mystack.printitems() System.out.println(" ") System.out.println("-----------") String popobject2 = mystack.pop() System.out.println("Data after pop object " + popobject2 + " :") mystack.printitems() System.out.println(" ") System.out.println("-----------") StackTest.java Stack.java 9

$ javac StackTest.java $ java StackTest Initial data : Kenji,Nobu, ----------- Data after push Taro : Kenji,Nobu,Taro, ----------- Data after pop object Taro : Kenji,Nobu, ----------- Data after pop object Nobu : Kenji, ----------- 8-3 (Queue) push/shift Komachi, Yamabiko, Tsubasa, Nasuno Komachi, Yamabiko 10

8.5 2 1. (Circle) x,y r 1 main() (x=10, y=5, r=4) 1 x 7 y 10 2. B 8 [1,6,15,12,7,9,23,2,10,4,20] 3. (Queue) push/shift Komachi, Yamabiko, Tsubasa, Nasuno Komachi, Yamabiko 2 1. // Cell.java public class Cell { int item // Cell next 2. [1,6,15,12,7,9,23,2,10,4,20] 3. 1) Java, 3, David Flanagan 2),, 3) 3 Java,, 4) JAVA,, Patrick Niemeyer & Joshua Peck, 5) Java,, Paul Tyma, Gabriel Torok, & Troy Downing, 11