public class Example2_1 {
public static void main (String args[]){ char c='a'; System.out.println("zimu"+c+"in the unicode canlender consition:"+(int)c); System.out.println("zimubiao:"); for(int i=(int)c;i<c+25;i++){ System.out.print(""+(char)i); } }}public class Example2_2 {
public static void main (String args[]){ byte a=120; short b=130; int c=2200; long d=8000; float f; double g=0.1234567812345678; a=(byte)b; c=(int)d; f=(float)g; System.out.println("a="+a); System.out.println("b="+b); System.out.println("c="+c); System.out.println("d="+d); }}public class Example2_3 {
public static void main (String args[]){ char c='A'; float f=123.456789f; double d=123456.12345678; long x=5678; System.out.printf("%c%n10.3f%n%f,%12d%n%d",c,f,d,x,x=x+2); }}
import java.util.*;
public class Example2_4 { public static void main(String arg[]){ Scanner reader=new Scanner(System.in); double sum=0; int m=0; while(reader.hasNextDouble()){ double x=reader.nextDouble(); m=m+1; sum=sum+x; } System.out.printf("%d个数的和为%f\n",m,sum); System.out.printf("%d个数的平均值是%f\n",m,sum/m); }}
public class Example2_5 {
public static void main (String args[]){ int[]a={1,2,3}; int[]b={10,11}; System.out.println("address a:"+a); System.out.println("address b:"+b); System.out.printf("b[0]=%-3db[1]=%-3d\n",b[0],b[1]); b=a; System.out.println("address a"+a); System.out.println("address b"+b); b[1]=888; b[2]=999; System.out.printf("a[0]=%-5da[1]=%-5da[2]=%-5d\n",a[0],a[1],a[2]); System.out.printf("b[0]=%-5da[1]=%-5da[2]=%-5d\n",b[0],b[1],b[2]); }}问题:
Example2-3中,在编译和运行的时候都正常通过了。但是,通过上传的图片,也可以看到,在编译运行成功之后,还提示一段文字,应该是抛出异常的意思,也许是没有引包?异常处理还没有学到,再看看异常处理那里,看看可不可以找到问题吧。