在java中,有一种方法可以从构造函数调用void方法。我尝试了类似的方法,但收到一条错误消息,指出编译器找不到符号方法 printThis(java.lang.String):
public class Date{
public Date(String inString){
String s = inString;
String b;
b.printThis(s);
}
public void printThis(getString)
{
System.out.printf(System.out.printf( new SimpleDateFormat("MM/dd").format(new SimpleDateFormat("MM/dd").parse(getString) ) );
}
最佳答案
您想要printThis(s)
- 编译器正在 String 实例上查找 printThis 方法,但该方法不存在。
关于java - Java中void方法调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1809420/