| Author |
JOptionPane.showInputDialog problem
|
kunagu varun
Ranch Hand
Joined: Apr 13, 2010
Posts: 38
|
|
What i am trying to do is to get a character as an input and test whether it is vowel or not. For this purpose i want to use input box to get the input..This is the actual code i am trying to run ..
I am always getting the following error
File: G:\Java Projects\simple\JSwitch.java [line: 8]
Error: G:\Java Projects\simple\JSwitch.java:8: inconvertible types
found : java.lang.String
required: char
I have also tried with the following...
Please help me....
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1788
|
|
Error: G:\Java Projects\simple\JSwitch.java:8: inconvertible types
found : java.lang.String
required: char
The method returns a String NOT a char. You can't assign a String to a char.
So assign a String to a String.
|
 |
kunagu varun
Ranch Hand
Joined: Apr 13, 2010
Posts: 38
|
|
ya thank you for the response..
I have also tried by initializing it as String.. If i do it so,i cannot use the variable inside switch
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1788
|
|
|
Read the String API for a method that will allow you to extract a char from the String.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Make sure to check if the return value is null - if that is the case the user pressed Cancel or pressed the X. Also check if the entered string contains no characters at all.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: JOptionPane.showInputDialog problem
|
|
|