I\'m following the CS106A lectures online. I\'m going through the code on Lecture 12, but it\'s giving me errors in Eclipse.
This is my code. It seems the error is beca
You should be defining your method outside of main, like:
public class YourClass
{
public static void main(String... args)
{
}
public char yourMethod()
{
//...
}
}
Java does not support nested methods; however, there are workarounds, but they are not what you're looking for.
As for your question about args
, it is simply an array of Strings
that correspond to command line arguments. Consider the following:
public static void main(String... args) //alternative to String[] args
{
for (String argument: args)
{
System.out.println(argument);
}
}
Executing via java YourClass Hello, World!
Will print
Hello,
Word!