I am trying to parse XML and display it into list view, but after running the app nothing happens -- the list is displayed but not with the XML data . I don\'t know if I am
If you have a String and you are sure that the only thing in it is a whole number without spaces, you can use Integer.parseInt(String)
to convert it to an integer. This method will throw an exception if the string isn't just the number.
You cannot directly change or reference your String
object to Integer
type because there is no parent-child
relationship between these two classes.
If you try to cast
a String
to a Integer
in such a way, it will raise a ClassCastException
.
String someValue = "123";
Integer intValue = (Integer) someValue; // ClassCastException Raise.
So if you want to change or reference a String
Variable to Integer
, you must use parsing techniques.
int intValue = Integer.parseInt(someValue); //this code will work for this.