java问题,我这个为什么报空指针异常
package三期JAVA;importjava.util.LinkedList;classMyList{privateLinkedListlist;publicvoid...
package 三期JAVA;
import java.util.LinkedList;
class MyList{
private LinkedList list;
public void MyList(){
list=new LinkedList();
}
public void put(Object obj){
list.addLast(obj);
}
public Object get(){
return list.removeLast();
}
}
public class Day19_5 {
public static void main(String[] args){
MyList list=new MyList();
list.put("1");
list.put("小李");
list.put("小张");
list.put("小陈");
System.out.println(list.get());
System.out.println(list.get());
System.out.println(list.get());
}
} 展开
import java.util.LinkedList;
class MyList{
private LinkedList list;
public void MyList(){
list=new LinkedList();
}
public void put(Object obj){
list.addLast(obj);
}
public Object get(){
return list.removeLast();
}
}
public class Day19_5 {
public static void main(String[] args){
MyList list=new MyList();
list.put("1");
list.put("小李");
list.put("小张");
list.put("小陈");
System.out.println(list.get());
System.out.println(list.get());
System.out.println(list.get());
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询