+ 1
What does this code working?
public class Program { public static void main(String[] args) { int[ ] primes = {200, 330, 150, 170}; for (int t: primes) ; String [] names = {"Ajaml have","sherin have","muneer have","muhsin have"}; for (String x: names) { System.out.println(x+t); } } }
4 Answers
+ 7
It doesn't work because the variable t only exists in the for loop.
+ 2
you can access the variable t in 2nd loop only if it is nested loop of first one.For that.
..
remove the semicolon (;) after for(int t: primes) and surround the rest code with curly braces{}
0
thanks for all