java - How to return a char value from one method to another? -
This is what I have ...
{public static zero main String [] args) {// variable declaration four letters; GetLetter (); Letter = ""; System.out.println (letter)} Public Fixed int getLetter () {string text; Four letters; Text = joppenpen.showsputdialog ("Enter a letter."); Letter = text.charAt (0); Println (letter); Return letter; }} I want to get user input from the method getLetter and move it to the main method where I can display it on the screen. What am I doing wrong here?
getLetter () method should be returned type char no int . The reason for this is that you have assigned the local variable as letter type char .
In addition, methods are called by the method (); No 'method' .
Try the following code:
public class YourClass {public static zero main (string [] args) // // declaration four characters; Letter = getLetter (); Println (letter); } Public static char getLetter () {string text; Four letters; Text = joppenpen.showsputdialog ("Enter a letter."); Letter = text.charAt (0); Println (letter); Return letter; }}
Comments
Post a Comment