Basically, what I\'m trying to do, is get the item ID, and set a price from a ini, basically like: itemid:price but, i cannot simply do item.getId().toString(). I\'m trying to g
String itemId = Integer.toString(item.getId());
Primitive types (int, double, byte etc..) can't have methods. So use this :
String itemId = String.valueOf(item.getId());
Better:
String itemId = String.valueOf(item.getId());
Primitive types do not have methods, as they are not objects in Java. You should use the matching class:
Integer.toString(item.getId());
String itemId = Integer.toString(item.getId());
Another simple way is to just say "" + myInt
, assuming myInt is assigned.
So try:
item.getDefinitions().setValue("" + Integer.parseInt(split[1]));
Of course, you may want to wrap the line in a try/catch in case there are parsing errors or split[1] is null, index out of range, etc.
Alternatively, the method Integer.valueOf(str)
will return an Integer object (as opposed to a primitive) which will allow you to directly call the .toString() function.
item.getDefinitions().setValue(Integer.valueOf(split[1]).toString());
I particularly like .valueOf() because it caches many Integer objects.