Possible Duplicate:
(String) or .toString()?
I have an Object. Is it better to do like this
final String params = myObject.toString();
or
final String params =(String)myObject;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ToString will work with all objects (as long as they are not null). If you cast to a String then the object has to be a String, otherwise it will fail. So my guess is that you want a toString() call, but it depends on what you want to do!