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

java中的this和super

this
对象本身。public class ThisTest {
ThisTest tTest;
public ThisTest(){
tTest = this;
}
public void test(){
System.out.println(this);
}
public static void main(String arg[]){
new ThisTest().test();
}
}

成员方法引用。
成员变量引用。public class ThisTest {
String name;
String password;
public ThisTest(String name,String password){
this.name = name;
this.password = password;
}
public static void main(String arg[]){
ThisTest tTest= new ThisTest("fanqd","123456");
System.out.println(tTest.name);
System.out.println(tTest.password);
}
}
在构造函数内部第一行,调用本类另一个构造函数。public class ThisTest {
String name;
String password;
public ThisTest(int age){
this("liulingling", "666666");
}
public ThisTest(String name,String password){
this.name = name;
this.password = password;
}
public static void main(String arg[]){
ThisTest tTest= new ThisTest(20);
System.out.println(tTest.name);
System.out.println(tTest.password);
}
}
Super
父类方法引用。
父类成员变量引用。
在构造函数第一行,调用父类构造函数。public class SuperTest extends Father {
public SuperTest(String name,int age){
super(name, age);
}
public SuperTest(){
super(); //可以省略,子类会自动调用父类的默认构造函数
}
public static void main(String arg[]){
SuperTest st = new SuperTest("fanqd",30);
System.out.println(st.name);
System.out.println(st.age);
SuperTest df = new SuperTest();
}
}



相关文档:

深入浅出Java clone技术

 这是clone技术介绍的第一篇。本篇主要介绍对象clone技术的基本知识。
Clone基本知识储备
在Java里提到clone技术,就不能不提java.lang.Cloneable接口和含有clone方法的Object类。所有具有clone功能的类都有一个特性,那就是它直接或间接地实现了Cloneable接口。否则,我们在尝试调用clone()方法时,将会触发CloneNo ......

传智播客java学习 lucene初步

因为即将要学习lucene,所以我提前预习了lucene的相关知识,
1,lucene是众多搜索引擎中的一个,就像持久层除了Hibernate外也有很多其它框架
一样。Lucene是一个开发工具包,我们可以使用他为应用程序添加全文检索的功能。
2,目前已经有很多应用程序的搜索功能是基于 Lucene 的,比如 Eclipse 的帮助系
统的搜索功能。 ......

传智播客java学习 工作流初步


我今天预习了工作流的知识,我做了简单的笔记:
工作流(Workflow)
工作流就是工作流程的计算机化,即将工作流程中的工作如何前后组织在一起的
逻辑和规则在计算机中以恰当的模型进行表示并对其实施计算。
工作流要解决的主要问题是:为实现某个业务目标,在多个参与者之间,利用计
算机,按某种预定规则自动传递文 ......

java 学习心得体会(二)


66.  EJB容器提供的服务
        主要提供声明周期管理、代码产生、持续性管理、安全、事务管理、锁和并发行管理等服务。
67.  EJB规范规定EJB中禁止的操作有哪些?
        1.不能操作线程和线程API(线程API指非线程对象的方法如n ......

java去除字符串中的空格、回车、换行符、制表符

java去除字符串中的空格、回车、换行符、制表符
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringUtil {
public static void replaceBlank()
{
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
String str="I am a, I am Hello ok, \n new line ffdsa!";
System.out.p ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号