Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

char to object

 
liam fahey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have assignment due tommorrow. need to read a character from string, and pass to method as an object???
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look a the Character class in the API.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic