Skip to content

Instantly share code, notes, and snippets.

@behumble
Created October 19, 2019 01:40
Show Gist options
  • Save behumble/c21744303aa31a18952e88a74893f62f to your computer and use it in GitHub Desktop.
Save behumble/c21744303aa31a18952e88a74893f62f to your computer and use it in GitHub Desktop.
Java for-each loop which doesn't compile
public class ForLoop {
public static void main(String[] args) {
for(char c : "Hello") {
System.out.println(c);
}
}
}
@behumble
Copy link
Author

javac ForLoop.java
ForLoop.java:3: error: for-each not applicable to expression type
		for(char c : "Hello") {
		             ^
  required: array or java.lang.Iterable
  found:    String
1 error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment