JAVA+2复习题库(6)

2019-08-01 22:41

out.writeChars(descs[i]); out.writeChar('\\n'); }

//关闭数据输出流

out.close(); //创建数据输入流

DataInputStream in = new DataInputStream( new FileInputStream(\

double price; int unit; String desc; double total = 0.0; try {

//利用数据输入流读文件内容

while (true) {

price = in.readDouble();

in.readChar(); // throws out the tab unit = in.readInt();

in.readChar(); // throws out the tab

26

desc = in.readLine();

System.out.println(\

unit + \ desc + \

total = total + unit * price; } }

//捕获异常

catch (EOFException e) {

e.printStackTrace();

}

System.out.println(\

//关闭数据输入流

in.close(); } }

9、创建两个线程,每个线程打印出线程名字后再睡眠,给其它线程以执行的机会,主线程也要打印出线程名字后再睡眠,每个线程前后共睡眠5次。要求分别采用从Thread中继承和实现Runnable接口两种方式来实现程序。(即写两个程序)

27

答案略

28


JAVA+2复习题库(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:亿以上数的认识教学设计

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: