java
chlinwei
这个作者很懒,什么都没留下…
展开
-
java--单例
public class Main { public static void main(String[] args) { Singleton s = null; s = Singleton.getInstance(); s.print(); }}class Singleton{ private static final原创 2017-08-25 14:32:33 · 202 阅读 · 0 评论 -
java---工厂设计模式
public class Main{ public static void main(String [] args){ Fruit f = Factory.getInstance("apple"); f.eat(); Fruit f1 = Factory.getInstance("orange"); f1.eat(); }} interface Fruit{ publi原创 2017-08-23 17:06:00 · 228 阅读 · 0 评论 -
二叉树
树的操作原理:选择第一个数据作为根节点,而后比根节点小的放在根节点的左子树(左节点),比根节点大的放在根节点的右子树(右节点),取得的时候按照中序遍历的方式取出(左-中-右)import java.util.Arrays;public class test{ public static void main(String args[]){ B原创 2017-09-01 16:30:08 · 251 阅读 · 0 评论 -
java--集合输出
集合输出有四种方式:Iterator,ListIterator,foreach,Enumeration,集合就用Iteratorpublic class test { public static void main(String args[]) throws Exception { Set all = new HashSet(); all原创 2017-09-09 16:59:30 · 371 阅读 · 0 评论 -
java--set
TreeSet:有序,无重复元素public class test { public static void main(String args[]) throws Exception { Set all = new TreeSet<>(); all.add(new Book("Java开发",45.6)); all.ad原创 2017-09-09 15:30:20 · 322 阅读 · 0 评论 -
java--List
All Superinterfaces:Collection, IterableAll Known Implementing Classes:AbstractList, AbstractSequentialList, ArrayList, AttributeList, CopyOnWriteArrayList, LinkedList, RoleList, RoleUnresolve原创 2017-09-09 10:37:34 · 273 阅读 · 0 评论 -
java--序列化和反序列化
public class test{ public static void main(String args[]) throws Exception { ser(); dser(); } public static void ser() throws Exception{ //序列化 ObjectOutputStream oo原创 2017-09-08 15:45:47 · 250 阅读 · 0 评论 -
java--Scanner
public class test{ public static void main(String args[]) throws Exception { //System.in 是InputStrema对象 //BufferedReader构造接受Reader对象 //InputStreamReader将字节流变为字符流 Bu原创 2017-09-08 15:07:00 · 204 阅读 · 0 评论 -
java--BufferedReader
public class test{ public static void main(String args[]) throws Exception { //System.in 是InputStrema对象 //BufferedReader构造接受Reader对象 //InputStreamReader将字节流变为字符流原创 2017-09-08 14:24:23 · 230 阅读 · 0 评论 -
java生产者消费者模型
public class Main { public static void main(String args[]) { Info info = new Info(); new Thread(new Produtor(info)).start(); new Thread(new Customer(info)).start(); }原创 2017-08-30 15:55:51 · 203 阅读 · 0 评论 -
线程同步
一.代码块同步public class Main { public static void main(String args[]) { MyThread mt = new MyThread(); new Thread(mt,"票贩子A").start(); new Thread(mt,"票贩子B").start();原创 2017-08-30 12:13:35 · 231 阅读 · 0 评论 -
java--内存流操作 ByteArrayInputStream ByteArrayOutputStream
public class test{ public static void main(String args[]) throws Exception { ByteArrayOutputStream output = new ByteArrayOutputStream(); String str = "hello,world"; output.原创 2017-09-07 17:12:19 · 533 阅读 · 0 评论 -
java--多线程
public class Main { public static void main(String[] args) { MyThread m = new MyThread("线程A"); MyThread m1 = new MyThread("线程B"); MyThread m2 = new MyThread("线程C");原创 2017-08-29 19:26:29 · 222 阅读 · 0 评论 -
java--equals toString
public class Main { public static void main(String[] args) { Book b = new Book("三国演绎",20); Book b1 = new Book("三国演绎",20); System.out.println(b.equals(b1)); //yes Sy原创 2017-08-24 14:19:11 · 221 阅读 · 0 评论 -
java--代理设计模式
public class Main { public static void main(String[] args) { Subject subject = new RealSubject(); ProxySubject proxy = new ProxySubject(subject); proxy.operate(); }}原创 2017-08-24 10:40:18 · 206 阅读 · 0 评论 -
java--反射
反射能创建实例对象,但是比new 更加能解决耦合性public class test{ public static void main(String args[]) throws Exception { Class cls = Class.forName("com.lw.Book"); Constructor con = cls.getConst原创 2017-09-04 14:09:01 · 242 阅读 · 0 评论 -
java--文件复制FileInputStream FileOutputStream
public class test{ public static void main(String args[]) throws Exception { long start = System.currentTimeMillis(); if(args.length != 2){ System.out.println("命令执行错误")原创 2017-09-07 10:23:03 · 252 阅读 · 0 评论