The examples you show above are not good examples of how the two things might be different.
There might be a time when you want to save, hypothetically, several different types of variables into an array (maybe to return them back from procedure in one variable). Since arrays must be of one type, you make the array and Object array:
Code:
Object myArray[] = new Object[3]; //for example
To populate the array, you would have to CAST the variables to OBJECTS:
What you refer to as CONVERT-ing is merely for when you have a String that you know is a number and you would like to do some mathematical or logical operation on it:
Code:
String two = "1";
String one = "2";
if(Integer.parseInt(two) < Integer.parseInt(one))
{
String message = "What the heck is going on here!?!";
}
Follow?
There are other reasons one might want to cast objects, but I think the CONVERSION you are talking about is strictly related to using Strings as numbers.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.