|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
Java编译的是字节码,跟C++相反,启动不够快,效率不够高,难以精确控制内存,但是优点是编程比C++容易,代码比较安全但是容易留下性能隐患,跨平台靠字节码在各个平台复制(一处编译到处调试)/*
*@(#)ClsUsage.java1.004/12/25
*
*Youcanmodifythetemplateofthisfileinthe
*directory..JCreatorTemplatesTemplate_1Project_Name.java
*
*Youcanalsocreateyourownprojecttemplatebymakinganew
*folderinthedirectory..JCreatorTemplate.Usetheother
*templatesasexamples.
*
*/
packagemyprojects.clsusage;
importjava.util.*;
classClsUsage{
publicClsUsage(){
}
publicstaticvoidmain(Stringargs[]){
System.out.println("StartingClsUsage...");
ISplitPageisp=newuserPage(12);
isp.firstPage();
while(isp.hasPages())
{
isp.nextPage();
}
}
}
interfaceISplitPage
{
voidfirstPage();
voidnextPage();
booleanhasPages();
}
classdateObj
{
privateStringname;
privateintage;
privatebooleansex;
privateintid;
publicstaticintpersonID;
static
{
personID=1000;
}
publicdateObj(Stringna,intag,booleansx)
{
name=na;age=ag;sex=sx;
id=dateObj.personID++;
}
publicdateObj(Stringna,intag)
{
name=na;age=ag;sex=true;
id=dateObj.personID++;
}
publicintgetId()
{
returnid;
}
publicStringgetName()
{
returnname;
}
publicvoidsetName(Stringna)
{
name=na;
}
publicintgetAge()
{
returnage;
}
publicvoidsetAge(intdg)
{
age=dg;
}
publicbooleanisSex()
{
returnthis.sex;
}
publicvoidsetSex(booleansx)
{
sex=sx;
}
publicStringtoString()
{
return""+id+"-"+name+"-"+age+"-"+sex;
}
}
classuserPageimplementsISplitPage
{
//whichcanbeaccessedwithitselforson
//与本身或子类地点的包有关
protectedintpageCount;
protectedintpageIndex;
protectedjava.util.Vectorlist;
publicuserPage(intpages)
{
if(pages<=0)
this.pageCount=10;
intage=20;
booleansex=false;
list=newVector();
for(inti=0;i<pages;i++)
{
Stringna=""+i+"";
dateObjob=newdateObj(na,age+i,sex);
sex=!sex;
list.addElement(ob);
}
this.pageCount=pages;
this.pageIndex=1;
}
publicvoidfirstPage()
{
pageIndex=1;
dateObjob=(dateObj)list.get(pageIndex-1);
System.out.println("第一页"+ob.toString());
}
publicvoidnextPage()
{
pageIndex++;
if(pageIndex<=this.pageCount)
{
dateObjob=(dateObj)list.get(pageIndex-1);
System.out.println("第"+pageIndex+"页"+ob.toString());
}
}
publicbooleanhasPages()
{
returnpageIndex<=pageCount;
}
}
你说是sun公司对她研究的透还是微软?针对自己工具开发的.net性能上肯定会站上风的。 |
|