I need to create a class for the methods described in the interface as follows:
public interface MyStringInterface {
// Sets the value of the current string
public void setString(String str);
// Returns the current string
public String getString();
}
When I create a class with methods as below, there is always this error and wont let me proceed. What am I doing wrong? How should I proceed?
package seclass.assgn;
public class MyString implements MyStringInterface{
static String name;
public static void main(String[] args) {
setString("This is my sentence");
System.out.println(getString());
}
public void setString(String str){
name = str;
}
public String getString() {
return name;
}
}