What is wrong with my code?

Home » Programming & Design » What is wrong with my code?
Programming & Design No Comments

public class Messages{
public static void main(String[] args) {
public static void namePrinter() {
System.out.println("Ryan");
}

public static void wordPrinter() {
System.out.println("Golf");
}

public static void

public class Messages{
public static void main(String[] args) {
public static void namePrinter() {
System.out.println("Ryan");
}

public static void wordPrinter() {
System.out.println("Golf");
}

public static void incrementPrinter() {
int Myfirstnumber = 1;
System.out.println("My first number is" + Myfirstnumber);
System.out.println("1 + My first number is " +Myfirstnumber + 1);

}
}
}

It gives me about 12 error messages

Other answer:

Caribbean Man:
You have three method definitions nested within the main method. You cannot define a method within another method.
cisco:
You are declaring methods within a method, you can't do that in Java. Move wordPrinter(), wordPrinter(), and incrementPrinter() outside of main() and it will compile fine.

LEAVE A COMMENT