ITeye博客

JAVA

共 3 篇文章

对于面向对象的初步理解

abstract class Door { abstract void open(); abstract void close(); } interface Alarm { void alarm(); } class AlarmDoor extends Door implements Alarm { void open() { … } void close() { … } void alarm() { … } } 抽象->对象 接口->组件(应用) 某个抽象实现一个接口(一些功能)生成一个对象。

2010-08-05 10:06 · JAVA

使用StringBuffer变相实现参数的引用传递。

在网上搜了很多资料,多说java没有引用传递,只有值传递。后来发现可以使用StringBuffer变相实现。 void strAppend(StringBuffer str){ str.Append("world"); } public static void main(String args[]){ StringBuffer str = new StringBuffer("hello"); strAppend(str); System.out.println("str=" + str); } 结果:str=helloworld 其实java的io(nio)还是很强大的,用的好可以大大提高程…

2010-04-15 10:17 · JAVA

java的单态实现

public class Singleton { //唯一接口实例 private static Singleton instanse; //单态,接口调用方式:Singleton xxx = Singleton.getInstance(); public static Singleton getInstance(){ if(instanse == null){ try{ instanse = new Singleton(); }catch(java.lang.OutOfMemoryError err){ System.out.println("创建对象时内存溢出" + "::" + err…

2010-03-23 14:31 · JAVA