Can anyone tell me why the program is failing to execute in the third part i.e. when i m passing copy constructor?
It says that the identifier expected near Stud(studs)
class Stud
{
String name;
int rollno;
double per;
Stud()
{
name="";
rollno=0;
per=0.0;
}
Stud(String n,int rn,double p)
{
name=n;
rollno=rn;
per=p;
}
Stud(Studs)
{
name=s.name;
rollno=s.rollno;
per=s.per;
}
void display()
{
System.out.println(name+ "\t" +rollno+ "\t" +per);
}
}
class StudApp14
{
public static void main(String a[])
{
Stud s1=new Stud();
Stud s2=new Stud("Amit",501,65.0);
Stud s3=new Stud(s2);
s1.display();
s2.display();
s3.display();
}
}
Stud(Studs)
{
name=s.name;
rollno=s.rollno;
per=s.per;
}
What is “Studs”? there is no definition for it.
Maybe you meant