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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

Java2实用教程实验指导模版代码.docx

1、Java2实用教程实验指导模版代码Java-2实用教程实验指导模版代码上机实践1 初识Java实验1 一个简单的应用程序程序模板public class Hello public static void main (String args ) 【代码1】 ; import .*;public class FirstApplet extends Applet public void paint(Graphics g) ; 【代码1】;class SunRise public static void main(String args ) SquareEquation equation=new Sq

2、uareEquation(4,5,1); (); (-3,4,5); (); 上机实践4 继承与接口实验1 继承程序模板class People protected double weight,height; public void speakHello() yayawawa); public void averageHeight() height=173; average height:+height); public void averageWeight() weight=70; average weight:+weight); class ChinaPeople extends Peop

3、le 【代码1】 ;import DateExample public static void main(String args ) String str=(输入第一个日期的年份:); int yearOne=(str); str=(输入该年的月份:); int monthOne=(str); str=(输入该月份的日期:); int dayOne=(str); str=(输入第二个日期的年份:); int yearTwo=(str); str=(输入该年的月份:); int monthTwo=(str); str=(输入该月份的日期:); int dayTwo=(str); Calendar

4、 calendar=【代码1】 ;class BigIntegerExample public static void main(String args) BigInteger n1=new BigInteger(654321), n2=new BigInteger(456789), result=null; n1的二进制表示:+(2); n2的八进制表示:+(8); result=【代码1】;import .*;public class GuessExample extends Applet implements ActionListener int number; TextField in

5、putNumber; Label feedBack; Button nuttonGetNumber,buttonEnter; public void init() nuttonGetNumber=new Button(得到一个随机数); feedBack=new Label (无反馈信息,; ; inputNumber=new TextField(0,5); buttonEnter=new Button(确定); 【代码1】 ;import .*;import class SignalExample extends Applet implements ActionListener Button

6、 buttonRed,buttonGreen,buttonYellow; SignalCanvas signal; public void init() buttonRed=【代码1】 ;import .*;import .*;public class Boy extends Applet implements ActionListener Label a=new Label42; Button titleName=new Button7; String name=星期日,星期一,星期二,星期三, 星期四,星期五,星期六; Button nextMonth,previousMonth; int

7、 year=2005,month=1; CalendarBean calendar; Label showMessage=new Label(,; public void init() 【代码1】 etText(dayi); nextMonth=new Button(下月); previousMonth=new Button(上月); (this); (this); Panel pNorth=new Panel(), pSouth=new Panel(); (previousMonth); (nextMonth); (showMessage); (日历:+()+年+ ()+月 ); Scrol

8、lPane scrollPane=new ScrollPane(); (pCenter); 【代码5】etText(dayi); else if()=previousMonth) month=month-1; if(month1) month=12; (month); String day=(); for(int i=0;i42;i+) ai.setText(dayi); (日历:+()+年+()+月 ); class CalendarBean String day; int year=2005,month=0; public void setYear(int year) =year; pub

9、lic int getYear() return year; public void setMonth(int month) =month; public int getMonth() return month; public String getCalendar() String a=new String42; et(year,month-1,1); int 星期几=日历.get-1; int day=0; if(month=1|month=3|month=5|month=7|month=8|month=10|month=12) day=31; if(month=4|month=6|mont

10、h=9|month=11) day=30; if(month=2) if(year%4=0)&(year%100!=0)|(year%400=0) day=29; else day=28; for(int i=星期几,n=1;ih/2) goDown(man); if(yh/2) goUp(man); if(xw/2) goRight(man); public void mouseReleased(MouseEvent e) public void mouseEntered(MouseEvent e) public void mouseExited(MouseEvent e) public v

11、oid mouseClicked(MouseEvent e) public void goDown(Person man) boolean move=true; Rectangle manRect=(); int x=().x; int y=().y; y=y+50; (x,y); Rectangle belowRect=(); for(int i=0;i10;i+) Rectangle personRect=personi.getBounds(); if(personRect)&!=i) move=false; if(belowRect) move=false; if(move=true)

12、(x,y); public void goUp(Person man) boolean move=true; Rectangle manRect=(); int x=().x; int y=().y; y=y-50; (x,y); Rectangle aboveRect=(); for(int i=0;i10;i+) Rectangle personRect=personi.getBounds(); if(personRect)&!=i) move=false; if(aboveRect) move=false; if(move=true) (x,y); public void goLeft(

13、Person man) boolean move=true; Rectangle manRect=(); int x=().x; int y=().y; x=x-50; (x,y); Rectangle leftRect=(); for(int i=0;i10;i+) Rectangle personRect=personi.getBounds(); if(personRect)&!=i) move=false; if(leftRect) move=false; if(move=true) (x,y); public void goRight(Person man) boolean move=

14、true; Rectangle manRect=(); int x=().x; int y=().y; x=x+50; (x,y); Rectangle rightRect=(); for(int i=0;i=200) y=10; (x,y); try (200); catch(InterruptedException e2) if(dead=true) 【代码5】 ;public class SecretExample public static void main(String args ) File fileOne=new File(), fileTwo=new File(); char

15、 b=new char100; try FileReader in=【代码1】;public class ReadExample public static void main(String args ) File file=new File(c:/1000,); File tempFile=new File(); try FileReader inOne=【代码1】;public class RandomExample public static void main(String args);import .*;public class ObjectExample public static

16、 void main(String args ) Calendar calendar1=(); ;import .*;import .*;import .*;public class ReadFile extends Applet implements ActionListener,Runnable File file; Choice choice; TextArea text; Thread thread; String item=null; Button button; URL url; public void init() choice=new Choice(); thread=new

17、Thread(this); int N=(getParameter(总数); for(int i=1;i=N;i+) (getParameter(i); button=new Button(开始读取); text=new TextArea(12,40); (this); add(choice); add(button); add(text); public void actionPerformed(ActionEvent e) (null); item=(); item=(); if(!() thread=new Thread(this); try (); catch(Exception ex

18、p) public void run() try url=new URL(getCodeBase(),item); InputStream in= 【代码1】 ;import .*;import .*;import Client extends Frame implements Runnable,ActionListener Button connection; Socket socket=null; ObjectInputStream in=null; ObjectOutputStream out=null; Thread thread; public Client() socket=new

19、 Socket(); connection=new Button(连接服务器,读取文本区对象); add(connection,; (this); thread = new Thread(this); setBounds(100,100,360,310); setVisible(true); addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) (0); ); public void run() while(true) try TextArea text=(TextArea)(); add(

20、text,; validate(); catch(Exception e) break; public void actionPerformed(ActionEvent e) if()=connection) try if() else InetAddress address=(); InetSocketAddress socketAddress=【代码1】;import .*;import .*;import .*;public class Server public static void main(String args) ServerSocket server=null; Server

21、Thread thread; Socket you=null; while(true) try server=【代码1】tart(); ;import .*; import .*;class ImageCanvas extends Canvas Image image=null; public ImageCanvas() setSize(200,200); public void paint(Graphics g) if(image!=null) (image,0,0,getSize().width,getSize().height,this); public void setImage(Image image) =image; class Client extends Fram

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

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