Reputation: 21
//source code
int[] s = new int[]{1,2,3,4};
for(int i:s){
System.out.println(i);
}
----------------------------
//below is in the class file
for(int i$ = 0; i$ < b; ++i$) {
int i = a[i$];
System.out.println(i);
}
what's the use of the $? i$ is a pointer like c?
Upvotes: 0
Views: 507
Reputation: 201409
In this case, it is literally a variable named i$
. JLS-3.8. Identifiers reads (in part)
The "Java letters" include uppercase and lowercase ASCII Latin letters A-Z (
\u0041
-\u005a
), and a-z (\u0061
-\u007a
), and, for historical reasons, the ASCII underscore (_
, or\u005f
) and dollar sign ($
, or\u0024
). The$
sign should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems.
Upvotes: 5