aspose file tools*
The moose likes Java in General and the fly likes problem with converting java.lang.Object to java.lang.String[solved] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "problem with converting java.lang.Object to java.lang.String[solved]" Watch "problem with converting java.lang.Object to java.lang.String[solved]" New topic
Author

problem with converting java.lang.Object to java.lang.String[solved]

Raghavan Chockalingam
Ranch Hand

Joined: Dec 20, 2005
Posts: 77
I am not able to cast Object class to String class. Object class is from session object...I tried with static String.valueOf(Object)...it is supposed to return string but returns int....

[/CODE]
[ January 06, 2006: Message edited by: Raghavan Chockalingam ]

Raghavan
SCJP 6
Sameer Damle
Greenhorn

Joined: Jan 05, 2006
Posts: 14
just check the return type of your getMemberId(userName) method........

i think it must be int.... and you are returning that value in a String variable...


I think like I'm diagonally ||||<br />parked in a parallel universe.\\\\
Raghavan Chockalingam
Ranch Hand

Joined: Dec 20, 2005
Posts: 77
This is the member function of MemberBean class
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42292
    
  64
I am not able to cast Object class to String class.


You're not casting an Object to a String, you're trying to use an int where a String is required. Try

memberId = new Integer(memberBean.getMemberId(userName)).toString();

The line

String userName = String.valueOf(session.getAttribute("userName"));

could be written as

String userName = (String) session.getAttribute("userName");

but it should work as it is.


Ping & DNS - my free Android networking tools app
Raghavan Chockalingam
Ranch Hand

Joined: Dec 20, 2005
Posts: 77
Sameer was right, I was trying to store a return int variable in a String variable which I recognized now...
earlier, it was...


Thanks to all of your help guys...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with converting java.lang.Object to java.lang.String[solved]