I have two non-static methods which I want to call in a new method. How do i do this ?
I have tried .methodName() but when I try to compile I receive an error message saying "cannot find symbol - method methodName()"
I have two non-static methods which I want to call in a new method. How do i do this ?
I have tried .methodName() but when I try to compile I receive an error message saying "cannot find symbol - method methodName()"
public class TestClass {
public String firstMethod()
{
return "first Method";
}
public String secondMethod()
{
return "Second Method";
}
public static void main(String[] args)
{
TestClass object = new TestClass(); // create a object for class `TestClass`
System.out.println(object.firstMethod()); // access the non-static method by `classname.methodName`
System.out.println(object.secondMethod());
}
}
Output :
first Method
Second Method