+ 1
How to print the primes
public class Program { public static void main(String[] args) { int[ ] primes = {2, 3, 5, 7}; for (int t: primes) { System.out.println(t); } } }
8 Respostas
+ 1
Can you clarify to me of this program?
+ 1
OK,
Line 1:- You have declared an array named primes which can hold integer values and you have filled it with 2,3,5,7.
Line 2:- This is called an enhanced-for loop, So,it will get every element of your array(that is primes) one by one, and put it in a new temporary variable named t.And then It will proceed to Print it.
Hence this loop will print each number of your array ONE-BY-ONE, treating each element as t , temporarily.
Hope that helps.If not ,msg me.
+ 1
It means every number is stored to prime is temporary stored in t. And print one by one for (for loop).
+ 1
Correct @Shivam , if u still didnt understand, I can explain in hindi/Punjabi
+ 1
Ok.... I cleared properly....
Thanks
+ 1
@Shivam, Anytime bro.
0
?