Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
My Java compiler won't compile for statements like the following?
import java.util.*;
public class IterateNoIndex {
public void withoutIndex() {
List<String> trees = Arrays.asList("Maple", "Birch", "Poplar");
for(String tree: trees){
System.out.println(tree);
}
The for loop causes an error. I am using jdk1.4.02
I am wondering since there are several examples using similar loops. Even CoreJava has an example like this
2 Answers
- 1 decade agoFavorite Answer
looks like you're trying to use Generics with jdk 1.4.
Generics were introduced on Java5 (aka jdk1.5)... try compiling with any version since java5
Or use do it without Generics
- Anonymous5 years ago
The assertion would have not have been given any result, and by way of default Java does not enable it. it would attempt so whether a million grew to become into decrease than or equivalent to ((x*x)+(y*y)) and then do no longer something with the result. this would produce no code in any respect, so the Java compiler refuses it relatively than doing what you suggested (that's purely approximately never what you go with). possibly, you go with do something if that attempt is actual or fake, yet you never suggested what.