aspose file tools*
The moose likes Beginning Java and the fly likes char to object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "char to object" Watch "char to object" New topic
Author

char to object

liam fahey
Greenhorn

Joined: Jan 08, 2004
Posts: 1
Have assignment due tommorrow. need to read a character from string, and pass to method as an object???
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Take a look a the Character class in the API.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, liam!
Which part of the problem you've described are you stuck on? Is it getting a character from a String? Is it just turning a char into an Object? Is it both?
Note that for all of the Java primitive values, a wrapper type object can be created to hold the primitive value. In the case of a char, create a Character object.
char myChar = 'a';
Character myCharacter = new Character(myChar);


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Note that you might find the J2SE API documentation useful when trying to figure out such things, including how to get a character from a String.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: char to object