ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:90.13KB ,
资源ID:7969659      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7969659.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Java语言进阶实验指导书.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Java语言进阶实验指导书.docx

1、Java语言进阶实验指导书_Java语言进阶实验指导书福建农林大学计算机与信息学院实验一 Generic and Collections Framwork泛型与集合框架 一、实验目的:1. 了解Java集合框架的接口和实现类2. 理解泛型类、泛型接口、泛型方法的特点3. 掌握常用泛型集合接口及其实现类二、实验内容:1. 编写程序练习List集合的基本使用:2.设计学生管理类StudentManager(用List集合管理学生对象)。StudentManager类的功能包括添加学生、查询学生、删除学生、统计学生成绩等。需要设计表示学生对象的Student类,并用LinkedList或ArrayL

2、ist集合来管理可被数量的学生对象。另外还需要设计测试类Test来验证StudentManager的功能。 3. (Optional ) Write a generic method that returns the maximum element in a two-dimensional array.public static E extends Comparable E max(E list)三、实验要求:1、认真执行每一个步骤的,并作好记录。2、实验报告中给出配置的详细步骤和重要的截图。四、实验学时:2学时五、实验步骤:1、编写程序练习List集合的基本使用:1) 创建一个只能容纳Str

3、ing对象名为names的ArrayList集合;2)按顺序往集合中添加5个字符串对象:“张三”、“李四”、“王五”、“马六”、“赵七”;3)对集合进行遍历,分别打印集合中的每个元素的位置与内容;4)首先打印集合的大小,然后删除集合中的第3个元素,并显示删除元素的内容,然后再打印目前集合中第3个元素的内容,并再次打印集合的大小。代码如下:package zhoupeili;import java.util.*;public class L1 public static void main(String args) List names = new ArrayList(); names.add(

4、张三); names.add(李四); names.add(王五); names.add(马六); names.add(赵七); for (int i = 0; i names.size(); i+) System.out.println(第 + (i + 1) + 条数据 为: + names.get(i); System.out.println(集合大小为: + names.size(); names.remove(2); for (int i = 0; i names.size(); i+) System.out.println(第 + (i + 1) + 条数据 为: + names.

5、get(i); System.out.println(第3条数据为:+ names.get(2); System.out.println(集合大小为: + names.size(); 运行上述代码,观察并记录运行结果。2.设计学生管理相应类,比较与上一段代码的重要区别。实验二 Multithreading多线程 一、实验目的:1. 理解多线程的原理和机制2. 掌握Java内置多线程编程接口和相关的类_ dgdo pass sum by ref- _二、实验内容:1. Write a program that launches 1000 threads. Each thread adds 1 t

6、o a variable sum that initially is 0. You need to pass sum by reference to each thread. In order to pass it by reference, define an Integer wrapper object to hold sum. Run the program with and without synchronization to see its effect.2. .分析代码并解释三、实验要求:1、认真执行每一个步骤的,并作好记录。2、实验报告中给出配置的详细步骤和重要的截图。四、实验学

7、时:2学时五、实验步骤:1. Write a program that launches 1000 threads. Each thread adds 1 to a variable sum that initially is 0. You need to pass sum by ref- erence to each thread. In order to pass it by reference, define an Integer wrapper object to hold sum. Run the program with and without synchroniza- tion

8、to see its effect.2. dgdo pass sum by ref- _运行下列代码,记录结果,并分析死锁的原因 / Exercise29_11.java: Demonstrate dead lockpublic class Exercise29_11 private Object object1 = new Object(); private Object object2 = new Object(); public static void main(String args) Exercise29_11 test = new Exercise29_11(); public E

9、xercise29_11() new Thread1().start(); new Thread2().start(); class Thread1 extends Thread public void run() synchronized (object1) / do something try Thread.sleep(100); catch (InterruptedException ex) System.out.println(Attempt to acquire a lock on object2); synchronized (object2) / do something cla

10、ss Thread2 extends Thread public void run() synchronized (object2) / do something try Thread.sleep(100); catch (InterruptedException ex) System.out.println(Attempt to acquire a lock on object1); synchronized (object1) / do something 实验三 Networking网络编程 一、实验目的:1. 理解基于流与基于数据包的网络编程方式2. 掌握应用socket建立CS应用程

11、序的相关类的应用_ dgdo pass sum by ref- _二、实验内容: Write a program that enables two users to chat. Implement one user asthe server (Figure 30.24(a) and the other as the client (Figure 30.24(b). Theserver has two text areas: one for entering text and the other (noneditable) fordisplaying text received from the

12、 client. When the user presses the Enter key,the current line is sent to the client. The client has two text areas: one for receivingtext from the server, and the other for entering text. When the userpresses the Enter key, the current line is sent to the server. Name the clientExercise30_12Client a

13、nd the server Exercise30_12Server.三、实验要求:1、认真执行每一个步骤的,并作好记录。2、实验报告中给出配置的详细步骤和重要的截图。四、实验学时:2学时五、实验步骤:给定如下客户端的代码,请完成服务器端代码的编写。/ Exercise30_12Client.javaimport java.io.*;import .*;import java.util.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;public class

14、Exercise30_12Client extends JFrame / Text area for entering server text private JTextArea jtaServer = new JTextArea(); / Text area for displaying client text private JTextArea jtaClient = new JTextArea(); private PrintWriter output; public static void main(String args) new Exercise30_12Client(); pub

15、lic Exercise30_12Client() / Place text area on the frame setLayout(new GridLayout(2, 1); JScrollPane jScrollPane1 = new JScrollPane(jtaServer); JScrollPane jScrollPane2 = new JScrollPane(jtaClient); jScrollPane1.setBorder(new TitledBorder(Server); jScrollPane2.setBorder(new TitledBorder(Client); add

16、(jScrollPane2, BorderLayout.CENTER); add(jScrollPane1, BorderLayout.CENTER); jtaServer.setWrapStyleWord(true); jtaServer.setLineWrap(true); jtaClient.setWrapStyleWord(true); jtaClient.setLineWrap(true);/ jtaClient.setEditable(false); setTitle(Exercise30_12Client); setSize(500, 300); setDefaultCloseO

17、peration(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); / Center the frame setVisible(true); / It is necessary to show the frame here! try / Create a server socket Socket connectToServer = new Socket(localhost, 8000); output = new PrintWriter(connectToServer.getOutputStream(); new SendThread(co

18、nnectToServer).start(); new ReceiveThread(connectToServer).start(); catch(IOException ex) System.err.println(ex); jtaServer.addKeyListener(new KeyAdapter() public void keyPressed(KeyEvent e) if (e.getKeyCode() = e.VK_ENTER) output.print(jtaServer.getText(); ); class SendThread extends Thread SendThr

19、ead(Socket socket) / Keep sending to the client class ReceiveThread extends Thread ReceiveThread(Socket socket) / Keep receiving from the client 实验四 MVC in GUI (GUI中的MVC模式) 一、实验目的:1. 掌握MVC设计模式的概念。2. 掌握应用MVC模式开发图形用户界面应用程序的方法。_ dgdo pass sum by ref- _二、实验内容: (Creating a student table ) Create a table

20、for student records. Each record consistsof name, birthday, class status, in-state, and a photo, as shown in Figure 1. The name is of the String type; birthday is of the Date type; class status is one of the following five values: Freshman, Sophomore, Junior, Senior, or Graduate; in-state is a boole

21、an value indicating whether the student is a resident of the state; and photo is an image icon. Use the default editors for name, birthday, and in-state. Supply a combo box as custom editor for class status.代码d_报一个重要信报_Figure 1.三、实验要求:1、认真执行每一个步骤的,并作好记录。2、实验报告中给出配置的详细步骤和重要的截图。四、实验学时:2学时五、实验步骤:(请给出详细

22、代码,并加入代码注释,注释是成绩高低和判定是否抄袭的一个重要依据。)实验五 JDBC Programming (JDBC数据库编程) 一、实验目的:掌握应用JDBC技术访问数据库的方法。_ dgdo pass sum by ref- _二、实验内容: (Accessing and updating a Staff table) Write a Java application that views, inserts,and updates staff information stored in a database, as shown in Figure 1.The View button d

23、isplays a record with a specified ID. The Staff table is createdas follows:create table Staff (id char(9) not null,lastName varchar(15),firstName varchar(15),mi char(1),address varchar(20),city varchar(20),state char(2),telephone char(10),email varchar(40),primary key (id);Figure 1.三、实验要求:1、认真执行每一个步骤的,并作好记录。2、实验报告中给出配置的详细步骤和重要的截图。四、实验学时:2学时五、实验步骤:(请给出详细代码,并加入代码注释,注释是成绩高低和判定是否抄袭的一个重要依据。)

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1