例1
public class Example2_1 {
public static void main (String args[]) {
char ch1 = 'w',ch2 = '好';
int p1 = 32831,p2 = 30452;
System.out.println("\"" ch1 +"\"的位置:" + (int)ch1);
System.out.println("\"" ch2 +"\"的位置:" + (int)ch2);
System.out.println("第"" p1 +"个位置上的字符是:" + (char)p1);
System.out.println("第"" p2 +"个位置上的字符是:" + (char)p2);
}
}
例2
public class Example2_2 {
public stasic void main (String args[]) {
bytc 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)n;
System.out.println("b= " + b);
System.out.println("f= " + f);
}
}
例3
import java.util.Scanner;
public class Example2_3 {
java 作业
最新推荐文章于 2023-03-29 20:19:06 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)