java 对象地址与值的问题
packagework;publicclassG_study{intage,id;Stringname;staticcomputerbee;//这是什么?类名加上变量名;...
package work;
public class G_study {
int age,id;
String name;
static computer bee; //这是什么? 类名加上变量名; 只有当有类的类名是computer才能定义这么一个类型
static computer aaa;
void study() {
System.out.println("我在用"+bee.bread);//bee是一个对象?
}
public static void main(String[] args) {
G_study mine =new G_study();
computer sc =new computer();
sc.bread="dell";
mine.bee=sc;
computer nomine =new computer();
nomine.bread="dell";
mine.aaa=nomine;
mine.study();
System.out.println(aaa);
System.out.println(aaa.equals(bee));
System.out.println(aaa.bread.equals(bee.bread));
System.out.println(aaa==bee);
}
}
class computer {
String bread;
int a;
String sname;
computer(String bread,int a,String sname){
}
computer (){
}
}
为什么System.out.println(aaa.equals(bee));是flase? 展开
public class G_study {
int age,id;
String name;
static computer bee; //这是什么? 类名加上变量名; 只有当有类的类名是computer才能定义这么一个类型
static computer aaa;
void study() {
System.out.println("我在用"+bee.bread);//bee是一个对象?
}
public static void main(String[] args) {
G_study mine =new G_study();
computer sc =new computer();
sc.bread="dell";
mine.bee=sc;
computer nomine =new computer();
nomine.bread="dell";
mine.aaa=nomine;
mine.study();
System.out.println(aaa);
System.out.println(aaa.equals(bee));
System.out.println(aaa.bread.equals(bee.bread));
System.out.println(aaa==bee);
}
}
class computer {
String bread;
int a;
String sname;
computer(String bread,int a,String sname){
}
computer (){
}
}
为什么System.out.println(aaa.equals(bee));是flase? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |