-
Java简单数据类型按照精度级别由低到高的顺序是;
byte/short/char/int/long/float/double/ -
long型常量用后缀L
-
float型一定要加F
-
byte(-127~128),short(-2^15 ~ 2 ^ 15 -1)
-
(byte)128[将int强制转化为byte型]
-
System.out.println和System.out.printf的区别是,前者是另起一行输出,后者是直接在后面输出。
输出特殊的偏旁的汉字
代码:
//InputChinese,java
public class InputChinese{
public static void main (String arg[ ]){
char ch ='研',zifu = 0;
int p =22920,count = 5, position = 0;
System.out.printf("输出%d个石字旁的汉字:\n",count);
for(char c=ch;c<=ch+count;c++){
position = (int)c;
System.out.printf("%c(%d)",c,position);
}
System.out.printf("\n输出%d个女字旁的汉字:\n",count);
for(int n=p;n<=p+count;n++){
zifu=(char)n;
System.out.printf("%c(%d)",zifu,n);
}
}
}
编译结果: