• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java

 
sailaja cherukuri
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hiii hiii i am getting these errors ..how to avoid these errors

class Method
{
public static void main(String args[])
{
static int methods()
{
int amount=10000;
return amount;
}
System.out.println(" it returns 10000");
}
}

hiii i am getting these errorss......... but i am not getting why
these errors camee... i think every thing is correct but ...

Method.java:5: error:illegal start of expression
static int methods()

Method.java:5: error: ';' expected
static int methods()
 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch Sailaja. Please use code tags when referring to code:



Looks much better now.
 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The compiler is complaining because you are trying to nest the method called methods() inside the main() method , which is not allowed in Java language. Nested classes are allowed though, but that's a different concept.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic