

アレイリストをどうやって作ればいいですか？

[code]

    public class Driver {
        public static void main(String[] args) {
     Direction<String> list = new Earray<String>();
    list.add("11");
    list.add("345");
    list.add("56");
    list.add("52");
     
    System.out.println("List are: " + list);
    System.out.println(list.size());
     
    list.addAll();
    System.out.println(" List are" + list); 
    System.out.println(list.size());
     
    list.remove("11");
    System.out.println(" List are" + list); 
    System.out.println(list.size());
     
    list.contains();
    System.out.println(" List are" + list); 
    System.out.println(list.size());
     
    list.updateAll();
    System.out.println(" List are" + list); 
    System.out.println(list.size());
     
    list.isEmpty();
    System.out.println(" List are" + list); 
    System.out.println(list.size());
     
    list.clear();
    System.out.println(" List are" + list); 
    System.out.println(list.size());
     
    //tests for adding a null value
        }
     
    }
    
    public interface Direction<E> extends Iterable<E> {
      boolean add(E toAdd);
      boolean addAll(Collection<E> values);
      void clear();
      boolean contains(E e);
      boolean isEmpty(); 
      void updateAll(E oldValue, E newValue);
      boolean remove(E e) ;
      int size() ;
    }
    public class Earray<E> implements Direction<E>{
    I want to make something like this(example of Earray
    E[]Earray
    int size
    add(E toAdd)
    E[size]=toAdd
    size++)
     
    @Override
    public Iterator<E> iterator() 
    {
    return null;
    }
     
    @Override
    public boolean add(E toAdd) {
    return false;
    }
     
    @Override
    public boolean addAll(Collection<E> values) {
    //addAll() requires an instance of java.util.Collection. So I need to make a java.util.Collection, put items in there, and then pass it to arrayList variable.
    return false;
    }
     
    @Override
    public void clear() {
    }
     
    @Override
    public boolean contains(E e) {
    return false;
    }
     
    @Override
    public boolean isEmpty() {
    return false;
    }
     
    @Override
    public void updateAll(E oldValue, E newValue) {
     
    }
     
    @Override
    public boolean remove(E e) {
    return false;
    }
     
    @Override
    public int size() {
    return 0;
    }
     
    //but cannot use something like List<T> mylist = new ArrayList<T>(); 
    }
    
[/code]


CC BY-SA 4.0
2021-10-13T00:55:52.297
83055
2021-10-13T05:01:04.740
2021-10-13T05:01:04.740
22665
48622
question
java
オリジナルのアレイリストの作り方