Tested:
public class Series {
public static void main(String[] args) {
int arr[] = {1, 2, 3};
for (int var : arr) {
int i 1;
while (i <= var);
System.out.println(i++);
}
// TODO code application logic here
}
}
Output:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code – variable i might not have been initialized
at Series.main(Series.java:7)
B
E
B note the ; after while() it keeps running and does not print anything
B
B
TESTED
E
Tested:
public class Series {
public static void main(String[] args) {
int arr[] = {1, 2, 3};
for (int var : arr) {
int i 1;
while (i <= var);
System.out.println(i++);
}
// TODO code application logic here
}
}
Output:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code – variable i might not have been initialized
at Series.main(Series.java:7)
int i 1; must be int i = 1 => infinite loop: Answer:B