0

Line 33 is where I get the error and I'm not sure why....can someone please help me. Line 33 is the one that says reverse(). And public String reverse is the method in the class

public String reverse() {
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter anything in here make sure it is a letter or number..anything else will be destroyed");
    String a = scan.nextLine();
    String reverse = "";
    for (int i = a.length() - 1; i >= 0; i--) {
        reverse = reverse + a.charAt(i);
    }

    System.out.println("Here is your input in reverse: ");
    return reverse;
}

public static void main(String[] args) {
    reverse();
}
User9123
  • 1,643
  • 1
  • 8
  • 21
  • You call non static method reverse from static method. – User9123 Mar 17 '20 at 21:12
  • Make reverse method as static - public static String reverse() – kann Mar 17 '20 at 21:13
  • You can't call non static methods from static methods. So, you have two options: 1) add static keyword in reverse() method 2) Put reverse() inside a class that can be instanciated, so you can call new Reverse() and after call the method. – Ronaldo Lanhellas Mar 17 '20 at 21:16

0 Answers0