Error in Code: Non-static method cannot be referenced from a static context
Hey I am new to java and am in need of some help. Could you tell me why i am getting this error?
"non-static method reverse(java.lang.String) cannot be referenced from a static context"
Code:
import java.util.Scanner;
public class Reverse
{
public static void main(String args[])
{
Scanner keyboard = new Scanner(System.in);
String input = keyboard.next();
System.out.println(reverse(input));
}
public String reverse(String str)
{
if ((null == str) || (str.length() <= 1)) {
return str;
}
return reverse(str.substring(1)) + str.charAt(0);
}
}