The java rule extends and implements

During coding, I created a class extends ArrayList<>and implements Iterable<>. The code:

public class Testclass extends ArrayList<Object>, implements Iterable<Object> { }

Netbeans reported an error:

'{' expected

How to prevent this?

+5
source share
4 answers

From the comments:

error is '{' expected

code is public class Testclass extends ArrayList<Object>, implements Iterable<Object> { }

Remove this comma ,. It does not belong. This is just a syntax error.

Read the error message in the future . If you cannot interpret it, not even after a little Googling, just ask it here, fill in the entire error message and the code that caused it. Thus, you will get more suitable answers earlier than random guessing for a reason;)

+11
source

ArrayList Iterator. , Iterable?

, , ( ).

? , - . generics, , ?

, , Collection Iterator , . , .

+2

, ArrayList Iterator, :

public boolean hasNext()
public Object next()
public void remove()
+1

, , , ArrayList .

List ( Collection, ). - , yourList.iterator(). , , .

0
source

All Articles