This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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: 32819

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!