wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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 agree. Here's the link: http://aspose.com/file-tools
 
subject: java
 
Similar Threads
multiples project no output
noob with a looping interest rate problem
Program like ATM where person enters amount in dollars and cents but program uses int for monies
Infinite Decimal Numbers to Fractions
Confused on the idea of a Class file.