易截截图软件、单文件、免安装、纯绿色、仅160KB

java:手写MyLinkedList所有方法,增删改查

package arrays.myArray;
public class MyLinkedList {
 private int size = 0;
 private Node1 head = null;
 // 添加
 public void add(Object obj) {
  add(size, obj);
 }
 // 修改
 public void add(int index, Object obj) {
  if (null == head) {
   head = new Node1(obj, null);
  } else {
   if (0 == index) {
    head = new Node1(obj, head);
   } else {
    Node1 temp = head;
    for (int i = 0; i < index - 1; i++) {
     temp = temp.next;
    }
    temp.next = new Node1(obj, temp.next);
   }
  }
  size++;
 }
 // 移除
 public void remove(int index) {
  if (0 == index) {
   head = head.next;
  } else {
   Node1 temp = head;
   for (int i = 0; i < index - 1; i++) {
    temp = temp.next;
   }
   temp.next = temp.next.next;
  }
  size--;
 }
 // 查询
 public Object get(int index) {
  Node1 temp = head;
  for (int i = 0; i < index; i++) {
   temp = temp.next;
  }
  return temp.obj;
 }
 // 总长度
 public int size() {
  return size;
 }
}
class Node1 {
 Object obj;
 Node1 next;
 public Node1(Object obj, Node1 next) {
  this.obj = obj;
  this.next = next;
 }
}


相关文档:

Java中集合容器类List和Set的用法

List的用法
List包括List接口以及List接口的所有实现类。因为List接口实现了Collection接口,所以List接口拥有Collection接口提供的所有常用方法,又因为List是列表类型,所以List接口还提供了一些适合于自身的常用方法,如表1所示。
表1  List接口定义的常用方法及功能
从表1可以看出,List接口提供的适合于自身的 ......

java Annotation 拼装SQL语句

声明字段映射
@Target(ElementType.FIELD)  
@Retention(RetentionPolicy.RUNTIME) 
public @interface FiledRef
{
    String fieldName();
}
声明表映射
@Target(ElementType.TYPE)  
@Retention(RetentionPolicy.RUNTIME)
public @interface TableRef
{
 & ......

java 数据库连接池


数据库连接池,是一种相当实用的应用程序。它可以保存、维护及创建用户所需的数据库连接。从而使得用户得到一个连接的时间降低90%以上。大大提升了数据库访问的反应时间。
这个是一个开源的代码。大家可以修改它、使用它。
希望我的代码能对大家有用。
此代码,经过1000数量级的多线程并发访问测试。在四核CPU下也进行 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号