易截截图软件、单文件、免安装、纯绿色、仅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 Annotation 拼装SQL语句

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

java中文乱码解决总结


为什么说乱码是中国程序员无法避免的话题呢?这个首先要从编码机制上说起,大家都是中文和英文的编码格式不是一样,解码也是不一样的!如果中国的程序员不会遇到乱码,那么只有使用汉语编程。汉语编程是怎么回事我也不大清楚,应该是前年吧,我一朋友给我介绍汉语编程,怎么不错不错?当时因为学习忙没去关注这个,等我闲 ......

用Java操作Oracle日期类型字段

在java对oracle的操作中,日期字段是很头疼的事情,其实仔细研究一下也并不难掌握。
举个例子来说明:
表 book    中有name varchar2(20)//书籍名称,buydate Date //购买日期 两个字段。
已经创建了数据库连接Connection conn;
方法一、使用java.sql.Date实现比较简单的yyyy-mm-dd格式日期。
java.sql. ......

java:Object对象进行排序

package arrays.compara;
import java.util.Arrays;
public class Student {
 public static void main(String[] args) {
  Stu[] stus = new Stu[]{
    new Stu(156,34,"ad"),
    new Stu(153,24,"cc"),
    new Stu(126,37,"ab"), ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号