易截截图软件、单文件、免安装、纯绿色、仅160KB

九 java面向对象程序设计(this关键字)

九 java面向对象程序设计(this关键字)
/**
 * 面向对象之四
 * this关键字总结
 */
/*this关键字的第一种用法*/
//在方法中调用同类中的方法,这时的this可以省略.
class ThisPointer
{
 public void function1()
 {
  System.out.println("function1 is calling...");
 }
 public void function2()
 {
  System.out.println("function2 is calling...");
  this.function1();//调用同类中的function1;
  //this是指,这个对象的function方法.
 }
 public void function3()
 {
  System.out.println("function3 is calling...");
  function2();//相当于this.function2().传入的是同一个对象,所以this可以省略.
 }
}
/*this关键字的第二种用法*/
//指明类中与方法参数同名的成员变量.
class Pointer
{
 private int i;
 private String str;
 public void function(int i,String str)
 {
  this.i = i;
  this.str = str;
  //通过this,将function方法中同名的i,str和成员变量予以区分.
  System.out.println("i = " + i + " , " + "str = " + str);
 }
}
/*this关键字的第三种用法*/
//作为一个对象,参与到类的方法中
class Container
{
 private String name;
 public void setName(String name)
 {
  this.name = name;
 } 
 public String getName()
 {
  return name;
 }
 private Components com;
 public void addComponents()//在容器中添加部件,
 {
  //com = new Components(new Container());
  //虽然这样写没问题.但表示,在新创建一个部件的同时,又创建一个容器,然后将新部件加到新容器上.
  
  com = new Components(this);
  //用this表示这个容器类的对象,所以我们每次产生新部件是,都是加入到这个容器对象上的.
  System.out.println(" is loading...");
 }
}
class Components
{
 private Container c;
 public Components(Container c)
 {
  this.c = c;//部件类的构造方法指明


相关文档:

sql 2005 存储过程分页 java 代码

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列 ......

java 乱码

1。数据库 
在创建的时候,指定其编码为UTF-8. 
  (1)oracle: 
SQL> select userenv('language') from dual; 
USERENV('LANGUAGE') 
--------------------------------------------- 
SIMPLIFIED CHINESE_CHINA.UTF8 
SQL> 
jdbc url无须指定编码。 
& ......

JAVA开源工作流

    Willow
由Huihoo Power开发详细可到其中文主页查看。
更多Willow信息
OpenWFE
OpenWFE是一个开放源码的Java工作流引擎。它是一个完整的业务处理管理套件:一个引擎,一个工作列表,一个Web界面和一个反应器(存放自动代理)。它可以可以跟你的程序很好的给合。
更多OpenWFE信息
jBpm
jBpm是一个 ......

java 操作XML文件(片段)

//create a new Document
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document d = db.newDocument();

//add root Node
Element noteuser = d.createElement("note-users");
d.appendChil ......

Java虚拟机参数 XX等相关参数应用

通常,我们为了避免内存溢出等问题,需要设置环境变量
JAVA_OPTS    -Xms256M -Xmx512M 等,【对于服务器,一般都设置成一样的】
但是有的时候可能这样的设置还会不行(比如,当Server应用程序加载较多类时,即jvm加载类时,永久域中的对象急剧增加,从而使jvm不断调整永久域大小,为了避免调整),你可以使 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号