• Post Reply Bookmark Topic Watch Topic
  • New Topic

String to char

 
Phil Campaigne
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am storing a flag in the database as type char, but it is set from a web page request object as a string. I need to convert it from type String to char in java. I tried String.charAt(0) which seems to convert to a char type untill I assign it to a variable of type char:
char processed = processed_string.charAt(0);
when I execute this I get the error message: type undefined.

Any ideas what I am doing wrong?
Thanks in advance,

Phil
 
Rick Portugal
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked for me.That prints "a" for me, as I would expect. You must have something else wrong in your code. Hope that helps. If not, provide the code and we'll see if we can help.
 
Phil Campaigne
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for assuring me that I was on the right track. This led me to discover that the problem was elsewhere in my constructor and variable assignment.

I'm all set now.
Thanks again,
Phil
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!