jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes identifier expected - single error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "identifier expected - single error" Watch "identifier expected - single error" New topic
Author

identifier expected - single error

Al H
Greenhorn

Joined: Apr 27, 2008
Posts: 3
Hi,

I am a first year student and have an issue that I suspect is very simple and hope that someone can help me out!
I am looking to take in a value via a dialogue, parse it to Integer and then validate that it is greater than 600. I am getting one <identifier> expected error on line 21. Help please!!

Here is the code....

marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

When you define your method, you need to provide an argument type, followed by an identifier name. You are missing the argument type...

public static boolean checkFee( [type?] inFee )


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
if your declaration

public static boolean checkFee(inFee)

What is the type of the parameter inFee?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi,

Welcome to JavaRanch!

I couldn't answered this faster if you'd indicated which was line 21; try to do that next time, OK?

It's this line:

public static boolean checkFee( inFee )

You have to specify a data type for the parameter "inFee". In main(), you're passing "inputFee" as the argument, but I think that's an error; you presumably want to check the number, not the String, so I think you want to pass "fee". Then you can change "fee" from being a static member to just being a local variable in main(). Make sense? SO with that change, line 21 would be something like

public static boolean checkFee(int fee )


[Jess in Action][AskingGoodQuestions]
Al H
Greenhorn

Joined: Apr 27, 2008
Posts: 3
Thanks Ernest, Edwin and Marc - and yes I will include the line in question in future!

I have made the change as suggested and have a new error message
I assure you that I have spent hours trying to resolve this and other issues today - I am not just taking the easy route. Any thoughts would be thankfully received!


cannot find symbol
symbol : method showMessageDialog(<nulltype>,int,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, fee, " Successful Result", JOptionPane.PLAIN_MESSAGE );


The dot between JOptionPane.showMessageDialog is highlighted as being problematic
[ April 27, 2008: Message edited by: Al Hendo ]
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
You are passing an int instead of an Object into showMessageDialog.

Also, this showMessageDialog method will never run as the checkFee method will already have terminated.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Al H
Greenhorn

Joined: Apr 27, 2008
Posts: 3
Guys,
Thanks for your help. I appreciate the feedback but I am still not 100% sure how to fix.

I will follow up with my lecturer.

Cheers
Al
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: identifier expected - single error