![]() |
| ||
| console.nextChar(); HELP PLEASE??? Hi everyone, I need your help please What do i need to make my program read the next character using console.nextChar(); I've added the following: import java.util.*; static Scanner console = new Scanner(System.in); and then in the main: char ch; ch = console.nextChar(); and when i compile i get this error:: cannot find symbol symbol : method nextChar() location: class java.util.Scanner ch = console.nextChar(); can any 1 help me please?? thanks |
| ||
| Re: console.nextChar(); HELP PLEASE??? Scanner has no definition of method getChar. |
| ||
| Re: console.nextChar(); HELP PLEASE??? Quote:
for example: if user enters :: A 1 2 ch= console.nextChar(); g = console.nextInt(); h= console.nextInt(); what can i use instead of nextChar()?? Thanks in advance |
| ||
| Re: console.nextChar(); ??? You can use scanner.next() it returns string, but you can convert it to char. |
| ||
| Re: console.nextChar(); ??? just read it as String, convert it to an array of chars, or make a new Scanner class in which you define a nextChar() method :) |
| ||
| Re: console.nextChar(); ??? actually i found the answer String a= console.next(); char b = (char)a.charAt(0); thanks guys ;) |
| ||
| Re: console.nextChar(); ??? mmm.... just in case you need this again, a better way to do it is: variable = console.next().charAt(0); I hope it helps...:) |
| All times are GMT -4. The time now is 9:01 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC