File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "identifier expected - single error" Watch "identifier expected - single error" New topic

identifier expected - single error

Al H

Joined: Apr 27, 2008
Posts: 3

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

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
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

Joined: Jul 08, 2003
Posts: 24199


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

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

Joined: Apr 27, 2008
Posts: 3
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.

I agree. Here's the link:
subject: identifier expected - single error
It's not a secret anymore!