Skip to main content

Array[] is not Iterable?

1 reply [Last post]
vistall
Offline
Joined: 2009-08-15
Points: 0

Hi all.

I was used some code..

List a = new ArrayList();

see(a);

Object[] a2 = new Object[2]

see(s2);

Method see is

public void see(Iterable a)
{
for(Object $ : a)
{
//
}
}

but see can't use with array and i was add method

public void see(Object[] a)
{
for(Object $ : a)
{
//
}
}

But methods is the same.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
walterln
Offline
Joined: 2007-04-17
Points: 0

Arrays don't implement Iterable. The enhanced for-loop accepts either, [url=http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.14.2]see the JLS[/url].