该代码与第2行第12行有问题。请帮助。 代码在图像中。Java和printf
import java.util.Scanner;
public class first{
public static void main(String[] args){
Scanner b = new Scanner(System.in);
pro nc = new pro();
System.out.println("Enter the name of your first true crush");
String temp = b.nextLine();
nc.setname(temp);
nc.etc();
}
}
public class pro{
private String gname;
public String getName() {
return gname;
}
public void setName(String name) {
this.gname = name;
}
public void etc(){
System.out.printf("The name of your true crush was %s",getName());
}
}
请编辑您的问题发布代码,而不是截图。 – Arc676
此外,“有一些问题”并没有清楚地描述问题。请在问题中提供错误的完整说明。 –
可能的重复[为什么我得到一个简单的printf编译错误?](http://stackoverflow.com/questions/7774428/why-am-i-getting-a-compilation-errors-with-a-simple -printf) – thegauravmahawar