Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void add(Integer e){
- if(last == null){
- last = new Element(e,null);
- first = last;
- }else{
- Element tmp = last;
- last = new Element(e,null);
- tmp.setLink(last);
- if(first.getLink() == null)
- first.setLink(last);
- }
- }
- public void add(int i, Integer e){
- int count =1;
- Element temp = first;
- Element temp2;
- Element temp3 = first;
- if(last == null || first.getLink() ==null)
- add(e);
- else {
- while (count!=i){
- temp = temp.next();
- count++;
- }
- first = new Element (e,temp);
- temp.setLink(temp.next());
- while(temp3.hasNext()){
- temp3 = temp3.next();
- }
- last = temp3;
- }
- }
Add Comment
Please, Sign In to add comment