package com.codegym.task.task17.task1713;
import java.util.*;
/*
Shared list
*/
public class Solution implements List<Long>{
private ArrayList<Long> original = new ArrayList<>();
public static void main(String[] args) {}
@Override
public synchronized List<Long> boolean isEmpty(){
return original.isEmpty();
}
@Override
public synchronized List<Long> boolean contains(Object o){
return original.contains(Object o);
}
@Override
public synchronized List<Long> Iterator iterator(){
return original.iterator();
}
@Override
public synchronized List<Long> Object[] toArray(){
return original.toArray();
}
@Override
public synchronized List<Long> Object[] toArray(Object[] a){
return original.toArray(Object[] a);
}
@Override
public synchronized List<Long> add(Object o){
return original.add(Object o);
}
@Override
public synchronized List<Long> boolean remove(Object o){
return original.remove(Object o);
}
@Override
public synchronized List<Long> boolean containsAll(Collection c){
return original.containsAll(Collection c);
}
@Override
public synchronized List<Long> boolean addAll(Collection c){
return original.addAll(Collection c);
}
@Override
public synchronized List<Long> boolean addAll(int index, Collection c){
return original.addAll(int index, Collection c);
}
@Override
public synchronized List<Long> boolean removeAll(Collection c){
return original.removeAll(Collection c);
}
@Override
public synchronized List<Long> boolean retainAll(Collection c){
return original.retainAll(Collection c);
}
@Override
public synchronized List<Long> boolean equals(Object o){
return original.equals(Object o);
}
@Override
public synchronized List<Long> int hashCode(){
return original.hashCode();
}
@Override
public synchronized List<Long> Object get(int index){
return original.get(int index);
}
@Override
public synchronized List<Long> Object set(int index, Object element){
return original.set(int index, Object element);
}
@Override
public synchronized List<Long> void add(int index, Object element){
return original.add(int index, Object element);
}
@Override
public synchronized List<Long> Object remove(int index){
return original.remove(int index);
}
@Override
public synchronized List<Long> int indexOf(Object o){
return original.indexOf(Object o);
}
@Override
public synchronized List<Long> int lastIndexOf(Object o){
return original.lastIndexOf(Object o);
}
@Override
public synchronized List<Long> ListIterator listIterator(){
return original.listIterator();
}
@Override
public synchronized List<Long> ListIterator listIterator(int index){
return original.listIterator(int index);
}
@Override
public synchronized List<Long> List subList(int fromIndex,int toIndex){
return original.subList(int fromIndex, int toIndex);
}
}
Is this what they want? Help! I dont get the question..
Under discussion
Comments (10)
- Popular
- New
- Old
You must be signed in to leave a comment
Jason
29 September 2019, 23:40
It looks like your problem is that you a declaring new variables instead of using the ones from the constructor.
should be
0
ddi
30 September 2019, 12:15
That can be one of the problems, i have correct it but its not yet working... :
Any oder ideas?
0
Jason
1 October 2019, 21:04
oh it looks like you also put to return "List<Long>" in all you methods but that is not what it is asking for when you did the "original.<methodname>()" in the overridden methods is what satisfies the "delegate calls to the methods of the original object." so if I believe if you just put the method modifiers back to their original state you should be good to go
0
ddi
2 October 2019, 06:43
Sorry but i don´t get it. I have corrected the program to what u said, and now i am returning :
return original.containsAll(c);
not the List<Long>.
Can you explain it?
0
ddi
2 October 2019, 06:48
now i am calling this:
public synchronized List<Long>original boolean isEmpty(){
return original.isEmpty();
}
the error that i receive is that am i missing and ; in the method
0
Jason
2 October 2019, 16:35
well the conditions aren't asking you to return a list
0
Jason
2 October 2019, 16:39
that method would go...
0
ddi
10 October 2019, 13:20
So i set on error and get another lol now is this :
Solution is not abstract and does not override abstract method remove(int) in java.util.List
public class Solution implements List<Long> {
I am using this :
public class Solution implements List<Long> {
No idea where does the problem come from..
0
Jason
11 October 2019, 00:52
I'm kind of confused at this point. It might be worth submitting a new topic to get all of your current code republished so we can all read it over.
0
ddi
11 October 2019, 12:11
I have created a new post :) Thanks!
0