概述
package Chapter02;
import com.sun.net.httpserver.Filter;
public class Practice01 {
public static void main(String[] args) {
char chinaWord = ‘好’;
char japanWord = ‘差’;
char you = ‘u4F60’;
int position = 20320;
System.out.println(“汉字:”+chinaWord+“的位置:”+(int)chinaWord);
System.out.println(“日文:”+japanWord+“的位置:”+(int)japanWord);
System.out.println(position+“位置上的字符是:”+(char)position);
position = 21319;
System.out.println(position+“位置上的字符是:”+(char)position);
System.out.println(“you:”+you);
}
}
//#####################################
package Chapter02;
public class Practice02 {
public static void main(String[] args) {
byte b = 22;
int n = 129;
float f = 123456.6789f;
double d = 123456789.123456789;
System.out.println("b = "+b);
System.out.println("n = "+n);
System.out.println("f = "+f);
System.out.println("d = "+d);
b = (byte) n; //导致精度缺失
f = (float) d;//导致精度缺失
System.out.println("b = "+b);
System.out.println("f = "+f);
}
}
//由低到高:byte,short,char->int->long->float->double
//#####################################
package Chapter02;
import java.io.Reader;
import java.util.Scanner;
public class Practice03 {
public static void main(String[] args) {
System.out.println("输入若干个数,每输入一个数回车确认");
System.out.println("最后输入数字0结束操作");
Scanner = Reader = new Scanner(System.in);
double sum = 0;
double x = Reader.nextDouble();
while (x != 0) {
sum = sum + x;
x = Reader.nextDouble;
}
System.out.println("sum = " + sum);
}
}//public class YL01 {
最后
以上就是淡定路灯为你收集整理的java练习02的全部内容,希望文章能够帮你解决java练习02所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复