30/09/2018, 21:07
Cho em hỏi về lệnh copy Constructor Java với
class Student6{
int id;
String name;
Student6(int i,String n){
id = i;
name = n;
}
Student6(Student6 s){
id = s.id;
name =s.name;
}
void display(){System.out.println(id+" "+name);}
public static void main(String args[]){
Student6 s1 = new Student6(111,"Hoang");
Student6 s2 = new Student6(s1);
s1.display();
s2.display();
}
}
Em mới tập tành học Java thôi anh chị cho em hỏi là dòng Student6(Student6 s) là thế nào ạ, trong Constructor chỉ truyền đối số thôi vậy Student6 s là thế nào ai giúp đỡ em về kiến thức này với.
Bài liên quan
Cho mình cảm ơn nhé