wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Passing String to Character IS-A Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Passing String to Character IS-A Methods" Watch "Passing String to Character IS-A Methods" New topic
Author

Passing String to Character IS-A Methods

Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
Is there are better way than this ?
String aLetter = "A" ;
char [] charArray = new char[1] ;
charArray = aLetter.toCharArray() ;
boolean b = Character.isLetter(charArray[0]) ;
Thank you.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18715
    
    8

Using the "charAt(int)" method of String would reduce the number of lines of code in that example.
 
wood burning stoves
 
subject: Passing String to Character IS-A Methods