My first class...
import java.util.Scanner;
class MethodsANDInstances16A {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
MethodsANDInstances16B methObject = new MethodsANDInstances16B();
System.out.println("Enter name of first girlfriend or good friend here: ");
String temp = input.nextLine();
methObject.setName(temp);
methObject.saying();
}
}
My second class...
public class MethodsANDInstances16B {
private String girlName;
public void setName(String name){
girlName = name;
}
public String getName(){
return girlName;
}
public void saying(){
System.out.printf("Your first girlfriend or good friend was %s", getName());
}
}
I just watched a Tutorial on YouTube with basically the exact same code... and yet the printf statement doesn't work for me... but it does in the video I watched. I heard I need to change Settings in Eclipse (IDE I'm using), but I'm not sure?
This is the error I'm getting when I run it...
"Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, String)
at MethodsANDInstances16B.saying(MethodsANDInstances16B.java:11)
at MethodsANDInstances16A.main(MethodsANDInstances16A.java:10)"
Thank you.