The Artima Developer Community
Sponsored Link

Java Answers Forum
converting a char to a String

4 replies on 1 page. Most recent reply: Apr 22, 2003 11:34 PM by Vincent O'Sullivan

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
jake

Posts: 83
Nickname: onorok
Registered: May, 2002

converting a char to a String Posted: Apr 22, 2003 12:09 AM
Reply to this message Reply
Advertisement
How do I do it???? I am using a stringBuffer str

str.charAt(i);
want to compare it to a String.


Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: converting a char to a String Posted: Apr 22, 2003 12:22 AM
Reply to this message Reply
http://java.sun.com/j2se/1.4.1/docs/api/java/lang/String.html#valueOf(char)

jake

Posts: 83
Nickname: onorok
Registered: May, 2002

Re: converting a char to a String Posted: Apr 22, 2003 1:23 AM
Reply to this message Reply
yeah that realy doesn't help
can someone else help??

Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: converting a char to a String Posted: Apr 22, 2003 2:18 AM
Reply to this message Reply
OK... so you want to be spoonfed... Here u go...

convert the character that you are getting from your StringBuffer to String as follows:

String myStr = String.valueOf(str.charAt(i));

Now compare it with the string that you want to.

Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: converting a char to a String Posted: Apr 22, 2003 11:34 PM
Reply to this message Reply
> How do I do it

Useful information on how to easily convert from any of the following types to any of the others...
Mutable Primitives   Immutable Objects

boolean Boolean
signed byte Byte
unsigned byte Byte
short Short
char Character
int Integer
long Long
float Float
double Double
char[] String


...can be found at http://mindprod.com/products.html#CONVERTER

Vince.

Flat View: This topic has 4 replies on 1 page
Topic: Working with text files Previous Topic   Next Topic Topic: Reverse a string with recursion and iteration

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use