文章列表
package edu.basejava.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStrea ...
- 2006-11-28 21:05
- 浏览 761
- 评论(0)
package edu.basejava.util;
public class XmlDoc
{
private Instruction declare;
private Element root;
private static final String VERSION = "version";
private static final String ENCODING = "encoding";
private String version = "1.0";
private String encoding = " ...
- 2006-11-28 21:00
- 浏览 1067
- 评论(0)
package edu.basejava.util;
class Element
{
private String name;
private String text;
private Element parent;
private LinkedList<Attribute> attributes;
private LinkedList<Element> children;
public boolean isRoot()
{
return parent == null;
}
public boolean isLeaf()
{
return ch ...
- 2006-11-28 20:56
- 浏览 830
- 评论(0)
package edu.basejava.util;
class Attribute
{
private String name;
private String value;
Attribute(String name, String value)
{
this.name = name;
this.value = value;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getV ...
- 2006-11-28 20:50
- 浏览 892
- 评论(0)
package edu.basejava.util;
public class XmlSymbol
{
private enum symbol
{
encoding("encoding"), endprefix("</"), endsuffix("/>"), equal(
"="), prefix("<"), prefixi("<?"), suffix(">"), suffixi("?>" ...
- 2006-11-28 20:49
- 浏览 833
- 评论(0)
package edu.basejava.util;
public class Queue<V>
{
private static final int defaultSize = 10;
private int size;
private int front;
private int rear;
private V[] value;
public Queue()
{
this.setup(Queue.defaultSize);
}
public Queue(int size)
{
this.setup(size);
}
public void e ...
- 2006-11-28 20:33
- 浏览 865
- 评论(0)
package edu.basejava.util;
public class Stack<V>
{
private static final int defaultSize = 10;
private int size;
private int top;
private V[] value;
public Stack()
{
this.setup(Stack.defaultSize);
}
public Stack(int size)
{
this.setup(size);
}
public void push(V value)
{
if (th ...
- 2006-11-28 20:31
- 浏览 929
- 评论(0)
package edu.basejava.util;
public class ArrayList<V> implements IList<V>
{
private int defaultSize = 10;
private int maxSize;
private int numInList;
private int curr;
private V[] listArray;
public ArrayList()
{
setup(defaultSize);
}
public ArrayList(int size)
{
setup(size);
...
- 2006-11-28 20:30
- 浏览 932
- 评论(0)
package edu.basejava.util;
import java.util.Iterator;
public class LinkedList<E> implements IList<E>, Iterable<E>
{
private Link<E> head;
private Link<E> tail;
protected Link<E> curr;
public LinkedList()
{
this.setup();
}
LinkedList(E[] elements)
{
thi ...
- 2006-11-28 20:29
- 浏览 924
- 评论(0)
package edu.basejava.util;
public interface IList
{
public void clear();
public void insert(I item);
public void append(I item);
public I remove();
public void setFirst();
public void next();
public void prev();
public int length();
public void setPos(int pos);
public void setValue(I val);
...
- 2006-11-28 20:23
- 浏览 1042
- 评论(0)
关于Java 初始化,有多文章都用了很大篇幅的介绍。经典的<<Thinking in java>>更是用了专门的
一章来介绍Java初始化。但在大量有代码实例后面,感觉上仍然没有真正深入到初始化的本质。
本文以作者对JVM的理解和自己的经 ...
- 2006-11-25 12:33
- 浏览 668
- 评论(0)
Go deep into HashCode
为什么HashCode对于对象是如此的重要?
一个对象的HashCode就是一个简单的Hash算法的实现,虽然它和那些真正的复杂的
Hash算法相比还不能叫真正的算法,它如何实现它,不仅仅是程序员的编程水平问题,
而是关系到你的对象在存取是性能的非常重要的关系.有可能,不同的HashCode可能
会使你的对象存取产生,成百上千倍的性能差别.
我们先来看一下,在JAVA中两个重要的数据结构:HashMap和Hashtable,虽然它们有很
大的区别,如继承关系不同,对value的约束条件(是否允许null)不同,以及线程安全性
等有着特定的区别,但从实 ...
- 2006-11-25 12:26
- 浏览 1086
- 评论(1)