# Java 程式設計入門

(1)

(2)

## Outline

###  switch statements

(3)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 3

(4)

## 變數 Variables

### 

Primitive Data Types：此種類型的變數僅儲存相對應於資料型別所指定 的種類、大小、格式的資料

### 

（array）、類別（class）、介面（interface）皆為此類型

(5)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 5

(6)

## 變數 Variables

### 分開字組，例：CURRENT_USER_NUM

(7)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 7

(8)

## 運算子 Operators

### 

(9)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 9

(10)

## 運算子 Operators

### （implicit conversion）浮點數型態

(11)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 11

(12)

## 運算子 Operators

###  判斷左右運算元的關係，回傳 true 或 false

(13)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 13

(14)

## 運算子 Operators

###  位元邏輯運算子 Logical Operators

(15)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 15

## 運算子 Operators

### 

a += 2 Æ a = a + 2 a *= 3 Æ a = a * 3

(16)

## 運算子 Operators

### return x+1;

(17)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 17

## 運算子 Operators

)

### 

int x = 10;

double y = (double)x + 2;

(18)

### 

x + y / 100 (x + y) / 100 x + (y / 100)

(19)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 19

(20)

### 

Assignment Expressions，例：a = 2;

### 

Any Use of ++ or --，例：a++;

### 

Method Calls，例：System.out.println(“Hi!”);

### 

Object Creation Expressions，例：Integer intObject = new Integer(4);

(21)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 21

### 

Declaration Statement，例：int x = 2;

### 

Control Flow Statement

(22)

###  Control Flow Statements

(23)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 23

if(

)

{

### statements…

} else if(expression)

{

}

… else

{

}

(24)

switch(

) {

case

:

break;

case

:

### statements…

break;

default:

(25)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 25

### 

byte, short, int, char

### 

if-else 可用在條件式或範圍的判斷；switch 敘述僅能判斷 單一整數值

(26)

### 

/**************

……..

**************/

(27)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 27

(28)

###  基本 Java 類別庫

(29)

Dept. of Computer Science & Information Engineering,

National Taiwan University July 9, 2005 Page 29

Updating...

## References

Related subjects :