Effective Java: Item 1
Static Factory Methods
Four Advantages:
1) have names
2) not required to create a new object each time they are invoked
3) return an object of any subtype of their return type
4) reduce the verbosity of creating parameterized type instances.(for example: newInstance() method)
相关文档:
/**我这只讲 ListArray ,ListedList,HashMap
//ListArray 它是一个实现了List接口的类 ,List继承collection接口
//调用import java.util.ArrayList包,(这里两者任选其一) 完整的java集合存放在java.util包中
//特点:
1>.List是有序的集合
2>.List可以有重复的元素值
3>.使用索引来精确的访问元素值,
4& ......
import java.io.*;
public class QueueArray {
Object[] a; //对象数组,队列最多存储a.length-1个对象
int front; //队首下标
int rear; //队尾下标
public Qu ......
class Node
{
private Object obj;
private Node next;
//用数据域构造一个节点对象
public Node(Object obj)
{
this.obj=obj;
}
//返回下一节点的对象
public Node getNext()
{
return this.next;
}
//设置本节点的链域
public void setNext(Node next)
{
this.next=next;
}
//返回节点的数 ......
class Link
{
private Node head;
public Link(Node head)
{
this.head=head;
}
public void addNode(Node node)
{
Node p=head;
while(true)
{
if(!p.hasNext())
{
p.setNext(node);
break;
}
p=p.getNext();
}
}
//插入节
public void insertNode(Node p,Node q)
{
q.setNext(p.getNext());
p.se ......
一、面向对象的特征有哪些方面
1.抽象:
抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面。抽象并不打算了解全部问题,而只是选择其中的一部分,暂时不用部分细节。抽象包括两个方面,一是过程抽象,二是数据抽象。
......