View Single Post
  #1 (permalink)  
Old 03-30-2008, 05:58 PM
CyberFrog CyberFrog is offline
Member
 
Join Date: Mar 2008
Posts: 8
CyberFrog is on a distinguished road
Arguments in Main
Hey all, just writing up this little bit of code and now am a bit confused? all i now want to do insert the argument acquired from the Keyboard.readchar() command into my method via the calling of an object i.e. new? My IDE says its found my return type boolean but a char is required, but I already have a return in my method? Here is my code anyway (it doesn't like the char n = ..........etc line). Hope someone ca help?


Code:
package Chapter4; import cs1.Keyboard; //Always start with Capitals - Java synatx public class IsAlpha { //Creates a new instance of IsAlpha ////This is also a constructor(no return type) and same name as the class. public IsAlpha(){ } public boolean isalphabetic(char c){ if (Character.isLetter(c)){ return true; } else{ return false; } } public static void main(String[]args){ System.out.println("Please insert a character of your choice: "); char a = Keyboard.readChar(); IsAlpha charinp = new IsAlpha(); char n = charinp.isalphabetic(a); System.out.println(n); } }
Reply With Quote
Sponsored Links