第二章
1.编写一个应用程序,给出汉字“你” “我” “他” 在Unicode表中的位置。
/*
* 要观察一个字符在Unicode表中的顺序位置,可以使用int型类型转换
*/
public class Test {
public static void main(String[] args) {
System.out.println((int)'你');
System.out.println((int)'我');
System.out.println((int)'他');
}
}
2.编写一个java应用程序,输出全部的希腊字母。
/*
* 要观察要得到0~65535之间的数所代表的Unicode表中相应位置上的字符,必须使用char型类型转换
*/
public class Test {
public static void main(String[] args) {
char cStart='α', cEnd='ω';
for(char c = cStart; c <= cEnd; c ++) {
System.out.print(c+" ");
}
}
}
第三章
1.编写应用程序求1!+ 2!+ … + 10!
public class Test {
public static void main(String[] args) {
int sum = 0;
for(int i = 1; i <= 10; i ++) {
int f = 1;
for(int j = 1; j <= i; j ++) {
f *= j;
}
sum += f;
}
System.out.println(sum

本文提供Java实用教程第五版课后编程题答案,涵盖第二章到第六章,包括汉字Unicode位置、希腊字母输出、数学计算、循环结构应用、类的设计以及接口的实现等编程练习。
最低0.47元/天 解锁文章
653

被折叠的 条评论
为什么被折叠?



