面向对象1

在内存中创建对象

对象都是储存在堆中,然后在栈中储存局部变量,这个变量的储存的值就是想要的堆内存的地址

 

public class Dog {

String name;
String type;
String xingBie;
public void lookHome(){
System.out.println(name + "正在看家");
}
public void info(){                //哪个对象调用这个方法,那么里边属性就是这个对象的属性
System.out.println("姓名:"+ name + "种类:"+ type + "性别: "+ xingBie);
}
public static void Number(int a,int b,int c){
if(a>b && a > c){
System.out.println(a);
}else if(b > a && b >c){
System.out.println(b);
}else{
System.out.println(c);
}
}
public static void main(String[] args) {
Dog dog = new Dog();
dog.name = "小黄";
dog.type = "哈士奇";
dog.xingBie = "公的";
dog.lookHome();
dog.info();
Dog dog1 = new Dog();
dog1.name = "blot";
dog1.type = "超人狗";
dog1.xingBie = "母的";
dog1.lookHome();
int num1 = 5,
num2 = 7,
num3 = 1;
Number(num1, num2, num3);
}

}

转载于:https://www.cnblogs.com/xiaoyi667/p/10243205.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值