博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
this关键字的构造方法的使用
阅读量:2205 次
发布时间:2019-05-04

本文共 1178 字,大约阅读时间需要 3 分钟。

1 package com.wh.Object3; 2  3 public class this_Demo { 4     private String name; 5     private double price; 6     private int num; 7  8     public String getName() { 9         return name;10     }11 12     public void setName(String name) {13         this.name = name;14     }15 16     public double getPrice() {17         return price;18     }19 20     public void setPrice(double price) {21         this.price = price;22     }23 24     public int getNum() {25         return num;26     }27 28     public void setNum(int num) {29         this.num = num;30     }31 32     public this_Demo() {33         //this关键字的构造方法的使用 34         this("可乐", 2.5, 1001);35     }36 37     public this_Demo(String name, double price, int num) {38         this.name = name;39         this.price = price;40         this.num = num;41     }42 43     public static void main(String[] args) {44         /*45          * this("","",""); 代表一个构造方法46          */47         this_Demo th=new this_Demo();48         System.out.println(th.getName());49         System.out.println(th.getPrice());50         System.out.println(th.getNum());51     }52 }

 

转载于:https://www.cnblogs.com/1020182600HENG/p/5885263.html

你可能感兴趣的文章
AI 在 marketing 上的应用
查看>>
Logistic regression 为什么用 sigmoid ?
查看>>
Logistic Regression 为什么用极大似然函数
查看>>
SVM 的核函数选择和调参
查看>>
LightGBM 如何调参
查看>>
用 TensorFlow.js 在浏览器中训练神经网络
查看>>
cs230 深度学习 Lecture 2 编程作业: Logistic Regression with a Neural Network mindset
查看>>
梯度消失问题与如何选择激活函数
查看>>
为什么需要 Mini-batch 梯度下降,及 TensorFlow 应用举例
查看>>
为什么在优化算法中使用指数加权平均
查看>>
什么是 Q-learning
查看>>
用一个小游戏入门深度强化学习
查看>>
5 分钟入门 Google 最强NLP模型:BERT
查看>>
初探Java设计模式4:一文带你掌握JDK中的设计模式
查看>>
初探Java设计模式5:一文了解Spring涉及到的9种设计模式
查看>>
Java集合详解1:一文读懂ArrayList,Vector与Stack使用方法和实现原理
查看>>
Java集合详解2:一文读懂Queue和LinkedList
查看>>
Java集合详解3:一文读懂Iterator,fail-fast机制与比较器
查看>>
Java集合详解4:一文读懂HashMap和HashTable的区别以及常见面试题
查看>>
Java集合详解5:深入理解LinkedHashMap和LRU缓存
查看>>