Can't find constructor
Please some help:import java.util.*;
import java.lang.*;
publicclass Student
{
private String firstName;
private String lastName;
privatedouble[] testScores;
privatechar grade;
public Student()
{
firstName ="";
lastName ="";
}
public Student(String fName, String lName,double testScores,double list)
{
firstName = fName;
lastName = lName;
}
public String toString()
{
String str;
str = String.format("%-10s %-10s", firstName, lastName);
return str;
}
}
import java.util.*;
import java.lang.*;
publicclass TestStudent
{
publicstaticvoid main(String[] args)
{
Student student1 =new Student("John","Davies");
Student student2 =new Student("Peter","Johns");
System.out.println(student1);
System.out.println(student2);
}
}
I have error :
can't find symbol - constructor Student java.lang.String.java.langString
Thx
> I want in class studentest that user enters student
> first and last names
Well, if they first provide the names, and then you create the objects, you can pass the names to the constructor.
If you first create the object, and then want to set/change the names, you'll probably want a setter method.
jverda at 2007-7-12 14:56:24 >

import java.util.*;
public class StudentName
{
static Scanner console = new Scanner(System.in);
private String name;
public String getName()
{
return name;
}
//
//Method to set the name according to the parameters
public void setName(String userName)
{
name = userName;
}
}
What I wanted is array name that user can fill with f l name.
Thx
> import java.util.*;
>public class StudentName
>
> private String name;
>
>public String getName()
>
> return name;
> //
>
> /Method to set the name according to the parameters
>public void setName(String userName)
>
> name = userName;
>}
What I want is array "name" that user can fill with f l
name.
Thx