+ 1
Can someone please explain this code for me? What does "t" represent in the program?
//Java public class Program { public static void main(String[] args) { int[ ] primes = {2, 3, 5, 7}; for (int t: primes) { System.out.println(t); } } }
3 Respostas
+ 4
Steve Sajeev I thought "t" is a variable of type integer !?
+ 2
T represents type.
<T> specifically stands for generic type. According to Java Docs - A generic type is a generic class or interface that is parameterized over types.
0
't' there is an Integer variable defined in for loop as local scope, and in every iteration it is assigned a value from the array primes... Like t=2,next t=3, next t=4,next t=5.
So it is a user defined variable name..