I just realized that when I do this in Java:
for(int x = 0; x < 3; x++) { String bla = "bla"; bla += x.toString(); }
This (Netbeans in this case) will tell me that I cannot dereference my x-integer this way (as I would in C #).
Why is this?
Primitive types are not objects in Java, so you need to use other methods for this:
Integer.toString(x);
int is primitive, not Object, and therefore does not have a toString () method.
But you can do this:
String bla = "bla" + x;
int , . , int. Integer, . , toString, x String.
int
Integer
toString
x
String
x Integer, an int int , toString.
, x int, , . (, toString()). Integer, toString(), toString(), Java .
toString()
java (boolean int, short, char, long, float, double) .
However, they have a wrapper type (Integer, Character, ...) that have 1) utilyty static functions and 2) its instances can wrap primitive values.