Compile Error in Java Program?

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?

Oh my goodness,

  1. This is a processing forum not a java forum
  2. Your question is labled as p5js your code is
    obvisiously not.
  3. and you are instanciate a new Stoof object and the class doesn’t seem to have a setname etc methods only a main. Guess you want a NewJavaStoof one.

Cheers
—mnse

3 Likes