摘要: 一,DateFormat与MessageFormat一样都属于Format类的子类,此类专门用于格式化使用,java.util.Date本身已经可以很好的指定出一个具体的日期,但需要用DateFormat进行格式的设置。在DateFormat中存在以下的格式化操作:1,public final String format(Date date),接收Date型数据变为String类型数据取得DateFormat类的实例2,public static final DateFormat getDateInstance(),根据默认环境取得3,public static final DateForma 阅读全文
posted @ 2011-01-22 17:37 魔战 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 一,Demo1public class StringBufferDemo2 { public static void main(String args[]) { StringBuffer buf=new StringBuffer(); buf.append("hello").append(" world!"); System.out.println(buf.toString()); }}二,Demo2public class StringBufferDemo2 { public static void main(String args[]) { StringBuffer buf=new 阅读全文
posted @ 2011-01-22 16:00 魔战 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 在java中有两种方式实现线程,继承Thread类和实现Runnable接口方法一:一个类只要继承了Thread类,同时覆写了run()方法那么就能实现多线程。public class ThreadDemo extends Thread{ private String name; public ThreadDemo(String name) { this.name=name; } public void run() { for(int i=0;i5;i++) System.out.print("Thread运行:"+name+"i-"+i); }}public class Threa 阅读全文
posted @ 2011-01-22 14:36 魔战 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 一,Demo1public interface Demo T{ public void print(T param);}public class DemoImpl1T implements DemoT { public void print(T param) { System.out.print("param="+param); }}public class GenDemo15 { public static void main(String[] args) { DemoString demo=new DemoImpl1String(); demo.print("he 阅读全文
posted @ 2011-01-22 14:01 魔战 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 一,Demo1:public class PointT { public T x; public T y; public T getX() { return x; } public void setX(T x) { this.x = x; } public T getY() { return y; } public void setY(T y) { this.y = y; }}public class GenDemo { public static void main(String args[]) { PointFloat p=new PointFloat(); p.s 阅读全文
posted @ 2011-01-22 13:40 魔战 阅读(169) 评论(0) 推荐(0) 编辑