Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-30-2008, 05:58 PM
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); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-30-2008, 09:31 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,017
hardwired is on a distinguished road
Code:
C:\jexp>javac isalpha.java isalpha.java:14: incompatible types found : boolean required: char char n = charinp.isAlphabetic(a); ^ 1 error
The expression on the right side of the equals sign returns a boolean value. The declaration on the left is for a char. This is a type mismatch.
Try:
Code:
boolean n = charinp.isAlphabetic(a);
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-30-2008, 10:37 PM
Member
 
Join Date: Mar 2008
Posts: 8
CyberFrog is on a distinguished road
ah, thanksalot hardwired!! just getting used to the different return types : )
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding arguments of Servlet Java Tip Java Tips 0 01-25-2008 08:04 PM
repetition of 'arguments'(?) Igor New To Java 3 12-13-2007 11:08 AM
Variable No. of Arguments Gajesh Tripathi New To Java 2 10-31-2007 03:50 PM
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main barney New To Java 1 08-07-2007 08:10 AM
exception in thred main java.lang.nosuchmethoderror: main fernando Java Applets 1 08-06-2007 10:11 AM


All times are GMT +3. The time now is 11:20 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org