Student=new Student()和Student=new Student("name")有什么区别吗??希望有个具体的回答!!
来源:百度知道 编辑:UC知道 时间:2024/06/07 08:38:07
谢谢你的回答,我是初学者,还没听懂,不够具体呀!!
Student=new Student("name")给Student传递了"name"这一参数给相应的构造函数
Student=new Student()则是执行的没有参数的构造函数
用到了构造函数的重载
简单的说
第一个调用的是
Student() {内略}这个构造函数
第二个调用的是
Student(String str) {内略}这个构造函数 (参数名未必是str 只是举例)
比如Student是这样一个类
public class Student {
private String name;
public Student() {
name = "123";
}
public Student(String str) {
name = str;
}
}
那么第一个调用Student的name的值就是"123" 第二个调用name的值就是你传入的"name"
ObjectOutputStream oos=new ObjectOutputStream((new FileOutputStream("Student.tmp")));是什么意思?
书上说char*str="Student";相当于char*str=new char[8];strcpy(str,"Student")。那么...
“Good student as he is”=“he is Good student”?
“ s = (Student)t ”是什么意思
void new(struct student stu[N]) 这个怎么解释呢
student类
first year student&transfer student
在Visual Basic代码窗口中,语句Student.Font="宋体"中的Student是
You're a new student who___(has,have)had high score in entrance exam.
The new student whom I want to introduce to you has come.