public class MyNumber {
static String s1="您好。";
public static void main(String[] args) {
String s2 = "Java";
System.out.println(s1);
System.out.println(s2);
//byte short int long
byte mybyte = 124; //-128-127
short myshort = 32564; //-32768 - 32767
int myint=45784612;
long mylong = 46789451;
long result = mybyte + myshort +myint + mylong;
System.out.println("结果为:" + result);
// float double;
float f1 = 13.23f;
double d1 = 4562.12d;
System.out.println("float f1: " + f1);
System.out.println("double d1: "+ d1);
//char;
char word ='d',word2='@';
int p = 23045,p2=45213;
System.out.println("d在unicode 表中的顺序位置为:" + (int)word);
System.out.println("@在unicode 表中的顺序位置为:" + (int)word2);
System.out.println("unicode中第23045位是:"+(char)p);
System.out.println("unicode中第45213位是:"+(char)p2);
//转义字符:/ddd,/dxxx,/',//,/t,/r,/n,/b,/f;
char c1='//';
char char1 = '/u2605';
System.out.println(c1);
System.out.println(char1);
//布尔型:
boolean b ;
//boolean b1,b2;
b = true;
System.out.println(b);
//声明常量:
final double PI = 3.14;
int age = 23;
final int number;
number = 1234;
age =22;
System.out.println("常量PI的值为:"+PI);
System.out.println("赋值后number为:"+number);
System.out.println("int 型变量为:"+age);
}
}
Java从入门到精通 - Number char String float double
最新推荐文章于 2024-11-09 12:43:52 发布