Hello All, I’ve recently faced some issues… I’ve been following some online tutorials and added the code from given source, I modify it a little, and it doesn’t work.
First Java code which compiles on Interviewbit compiler.
package newjavastoof;
public class NewJavaStoof {
private String girlName;
public void setName(String name)
{
girlName = name;
}
public String getName()
{
return girlName;
}
public void saying()
{
System.out.printf("your first girlfriend was %s", getName());
}
}
2nd part of the code that doesn’t compile on line 11 and 12
package newjavastoof;
import java.util.Scanner;
public class Stoof {
public static void main(String[] args)
{
Scanner imput = new Scanner(System.in);
Stoof stoofObject = new Stoof();
System.out.println("Enter name of first gf here: ");
String temp = imput.nextLine();
stoofObject.setName(temp);
stoofObject.saying();
}
}
What’s wrong with it? I cant understand, Can anyone suggest me?