File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

char to object

liam fahey

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
author & internet detective

Joined: May 26, 2003
Posts: 33117

Take a look a the Character class in the API.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Dirk Schreckmann

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

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.
I agree. Here's the link:
subject: char to object
It's not a secret anymore!