This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java" Watch "java" New topic
Author

java

sailaja cherukuri
Greenhorn

Joined: May 02, 2013
Posts: 9
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

Joined: Jul 27, 2010
Posts: 1157

Welcome to the ranch Sailaja. Please use code tags when referring to code:



Looks much better now.


~ Mansukh
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

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.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: java
 
jQuery in Action, 3rd edition