データ型
データ型一覧
| 型 |
種類 |
バイト長 |
範囲 |
boolean
|
真or偽
|
|
true or false
|
byte
|
整数
|
1
|
-128~+127
|
char
|
1文字
|
2
|
-32768~+32767
|
short
|
整数
|
2
|
-32768~+32767
|
int
|
整数
|
4
|
-2147483648~+2147483647
|
long
|
整数
|
8
|
-263~263-1
|
float
|
小数
|
4
|
仮数部232、指数部28
|
double
|
小数
|
8
|
仮数部252、指数部211
|
定義
import java.io.*;
/* サンプルソース */
class sample02{
public static void main
(String args
[]){ // hellow world test
// 変数の定義
int a;
a = 100;
System.
out.
println("a = " + a
);
a = a * 2;
System.
out.
println("a = " + a
);
// 定数の定義
final int b = 1000;
System.
out.
println("b = " + b
);
}
}
変数の場合は型 + 変数名
定数の場合は"final" + 型 + 変数名
最終更新:2012年09月02日 10:31