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

数据结构(LinkedList的java实现)

 package day10;
import java.util.*;
public class MyLinkedList implements List
{
static class Node
{
public Object data;
public Node next;
public Node(Object data)
{
this.data=data;
}
}
private Node head;
public  MyLinkedList()
{
head=new Node(0);
}
public void add(int index, Object element)
{
if(index<(Integer)head.data)
{
Node current;
current=head;
for(int i=0;i<index;i++)
{
current=current.next;
}
Node p=new Node(element);
p.next=current.next;
current.next=p;   
head.data=(Integer)head.data+1;
}
else
{
System.out.println("ERROR!");
}
}
@Override
public boolean add(Object e)
{
Node current=head;
while(current.next!=null)
{
current=current.next;
}
Node p=new Node(e);
current.next=p;   
head.data=(Integer)head.data+1;
return true;
}
@Override
public boolean addAll(Collection c) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean addAll(int index, Collection c) {
// TODO Auto-generated method stub
return false;
}
@Override
public void clear()
{
head.next=null;
}
@Override
public boolean contains(Object o)
{
Node current=head;
while(current.next!=null)
{
current=current.next;
if(current.data.equals(o))
{
return true;
}
}
return false;
}
@Override
public boolean containsAll(Collection c)
{
// TODO Auto-generated method stub
return false;
}
@Override
public Object get(int index)
{
Node current;
current=head.next;
for(int i=0;i<index;i++)
{
current=current.next;
}
return current.data;
}
@Override
public int indexOf(Object o)
{
int i;
Node current=head;
for(i=0;i<(Integer)head.data;i++)
{
current=current.next;
if(current.data.equals(o))
{
break;
}
}
if(i<(Integer)head.data)
{
return i;
}
return -1;
}
@Override
public boolean isEmpty()
{
if(head.next!=null)
{
return true;
}
return false;
}
@Override
public Iterator iterator()
{
return new Iterator()
{
Nod


相关文档:

Java中的synchronized关键字

转载自 http://www.cn-java.com/www1/?action-viewnews-itemid-8283
由于同一进程的多个线程共享同一片存储空间,在带来方便的同时,也带来了访问冲突这个严重的问题。Java语言提供了专门机制以解决这种冲突,有效避免了同一个数据对象被多个线程同时访问。
  需要明确的几个问题:
  1)synchronized关键字可以作为 ......

c#如何调用SSl(https)加密的java写的Web Service

  今天领导吩咐一个任务,就是用.net技术去跳用java端写的webservers,而且要采用https访问方式,强制论证       
            String SecurelyStoredPassword = "adminsd";
      &nb ......

JAVA学习笔记②

1 编译命令
  javac [options] filename.java
  options->
  -classpath path 编译时需要的类路径
  -d directory 设定编译生成的.class文件输入到哪一个目录。
  关于-d小技巧 : 如果.java文件中使用了package语句, 例如 package com.test.maths; 加上-     d . 选项会帮助在当前目 ......

JAVA正则表达式使用方法

 正则表达式在字符串处理上有着强大的功能,sun在jdk1.4加入了对它的支持 
 
  下面简单的说下它的4种常用功能:
  
  查询:
  
以下是代码片段:
 String str="abc efg ABC"; 
 
String regEx="a|f"; //表示a或f 
 
 Pattern p=P ......

java反射机制


package com.infowarelab.java.test;   
  
import java.lang.reflect.Field;   
import java.lang.reflect.Method;   
  
public class ReflectTester {   
    @SuppressWarnings("unchec ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号