Java error "cannot find symbol" when using a constructor

8609 views java compilation
11

This is the class and it's constructor that I made. No problems while compiling.

{
    private String usuario="a";
    private String contrasena="a";
    private String nombre="a";
    private String apellido="a";
    private int dni=0;
    private int edad=0;

    public Usuario (String usuario, String contrasena, String nombre, String apellido, int dni, int edad)
    {
        this.usuario=usuario;
        this.contrasena=contrasena;
        this.nombre=nombre;
        this.apellido=apellido;
        this.dni=dni;
        this.edad=edad;
    }

And this is my main code where I use the constructor.

public class userTest
{
    public static void main (String args[])
    {
        Usuario philip;

        philip=new Usuario (user987, pass123, Philip, Fry, 11000111, 21);

    }
}


When compiling this part, the javac throws that error.

answered question

1 Answer

5

philip=new Usuario (user987, pass123, Philip, Fry, 11000111, 21);

The first 4 parameters are not defined.

If you are attempting to pass String values to the constructor, then the code should be:

philip= new Usuario ("user987", "pass123", "Philip", "Fry', 11000111, 21);  

posted this

Have an answer?

JD

Please login first before posting an answer.