资源描述:
《java集合与泛型程序设计》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、-信息工程学院实验报告的内容与格式按任课教师的要求书写。Java程序设计实验/实习报告学院:理学院班级:计算101姓名:洪龙龙学号:2010014549成绩:A通过JDBC方式操作数据库一、实验/实习过程实验题目1:源代码:/**Person.java*/packagelab6;classPerson{privateStringname;//姓名privateStringidstr;//身份证号publicPerson(Stringname,Stringidstr){this.name=name;this.idstr=idstr;}publicStringtoSt
2、ring(){return"姓名:"+name+"身份证号:"+idstr;}}/**Student.java*/packagelab6;classStudentextendsPerson{privateintchinese,maths,english;Student(Stringname,Stringidstr,intchinese,intmaths,intenglish){super(name,idstr);this.chinese=chinese;this.maths=maths;this.english=english;.---}publicStringt
3、oString(){returnsuper.toString()+"语文:"+chinese+"数学:"+maths+"英文"+english;}}/**Teacher.java*/packagelab6;classTeacherextendsPerson{privateintwage;Teacher(Stringname,Stringidstr,intwage){super(name,idstr);this.wage=wage;}publicStringtoString(){returnsuper.toString()+"工资:"+wage;}}/**Exerc
4、ise1.java*/packagelab6;importjava.util.*;publicclassExercise1{publicstaticvoidmain(String[]args){LinkedListmylist=newLinkedList();System.out.println("打印链表信息");mylist.add(newPerson("张三","12310000"));mylist.add(newStudent("李四","12320000",89,93,94));mylist.add(newTeacher(
5、"英明","12330000",40000));Iteratoriter=mylist.iterator();while(iter.hasNext())print(iter.next());System.out.println("=================================");System.out.println("将个人信息增加至表头和表尾,打印链表信息:");Studentstu=newStudent("洪龙龙","2010014549",70,59,92);.---mylist.addFirst(stu);mylist
6、.addLast(stu);iter=mylist.iterator();while(iter.hasNext())print(iter.next());mylist.removeFirst();System.out.println("=================================");System.out.println("将表头删除后,打印链表信息:");iter=mylist.iterator();while(iter.hasNext())print(iter.next());mylist.removeLast();System.out.
7、println("=================================");System.out.println("将表尾删除后,打印链表信息:");iter=mylist.iterator();while(iter.hasNext())print(iter.next());mylist.removeAll(mylist);System.out.println("=================================");System.out.print("调用LinkedList的函数removeAll后:");if(mylist.is
8、Empty