Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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 Java 8 in Action this week in the Java 8 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: 18150
    
    8

Using the "charAt(int)" method of String would reduce the number of lines of code in that example.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Passing String to Character IS-A Methods
 
Similar Threads
different question relating to the recursion
Arrays
How to read the complete contents of a file in a String?!
Read operation failed from Socket.
how do you convert CHAR TO STRING