This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Errors in Code

 
Linda Weeks
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you determine what I've done by these error messages? I've
tried everything I can think of. Thanks, Linda
A:\>javac Transfer.java
Transfer.java:137: Invalid method declaration; return type required.
clearTextFields();
^
Transfer.java:148: Class or interface declaration expected.
}
^
2 errors
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<pre>A method declaration requires that something be returned, even if it is void. For example:
void clearTextFields()
{
// stuff
}

or

are you trying to call a method with this statement and have failed to put it inside another method?
class Test
{
clearTextFields(); // this statement won't work here

public static void main( String[] args )
{
clearTextFields(); // the same statement will work here
}

void clearTextFields()
{
// stuff
}

}
 
parul patidar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
perhapes u missed 1 '}' or u have an extra '{' in ur application
parul patidar
Originally posted by Linda Weeks:
Can you determine what I've done by these error messages? I've
tried everything I can think of. Thanks, Linda
A:\>javac Transfer.java
Transfer.java:137: Invalid method declaration; return type required.
clearTextFields();
^
Transfer.java:148: Class or interface declaration expected.
}
^
2 errors

 
Steve Campbell
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Linda,
Everytime I've received this error it was because a brace "}" was missing somewhere.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic