Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:
JavaWorld Daily Brew

how to read a single character

Back to:
www.javaworld.com/javaworld/javaqa/1999-07/03-qa-readchar.html
.

when i try char c= System.in.read() it gives an error int cannot be changet to char since the return type of System.in.read()is int and not char what to do with this

Your rating: None Average: 5 (1 vote)

Try using this char ch =

Try using this
char ch = (char)System.in.read();

Yeah

i tried it..it worked..thanks a lot.. :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <p> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br /> <br> <strike>
  • Lines and paragraphs break automatically.
  • Use <!--pagebreak--> to create page breaks.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
Just checking to see if you're an actual person rather than a spammer. Sorry for the inconvenience.