java 代码。= -=
2024-08-23 06:44:01
package com.da;
//toString()方法,
//Object类重写。。。
public class ty {
private String name;
private int age;
private double high;
private String sex; public ty(String a, int b, double c, String d) {
name = a;
age = b;
high = c;
sex = d; } public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public int getAge() {
return age;
} public void setAge(int age) {
this.age = age;
} public double getHigh() {
return high;
} public void setHigh(double high) {
this.high = high;
} public String getSex() {
return sex;
} public void setSex(String sex) {
this.sex = sex;
} public String toString() { return "姓名:" + name + "年龄;" + age + "身高:" + high + "性别:" + sex;
} public boolean equals(Object o) {
if (((ty) o).name == this.name && ((ty) o).age == this.age) {
return true;
}
return false;
} public static void main(String[] args) {
ty d = new ty("啊", 3, 1.5, "男");
ty d1 = new ty("啊", 3, 1.1, "女");
System.out.println(d.toString());
System.out.println(d.equals(d1));
}
}
最新文章
- struts1和struts2的区别
- 洛谷10月月赛Round.3
- T-SQL 语句的理解
- JSon转化为DaTable
- linux包之procps之pmap命令
- C#网络通信
- [转]基于Spring + Spring MVC + Mybatis 高性能web构建
- POJ 2075 Tangled in Cables (c++/java)
- Nginx之RTMP
- SQL中内连接和外连接的问题!
- 理解TCP之Keepalive
- MVC 下 JsonResult 的使用方法(JsonRequestBehavior.AllowGet)
- HDU 3980 Paint Chain (sg函数)
- Knockout: 使用knockout validation插件进行校验, 给未通过校验的输入框添加红色边框突出显示.
- 56. Merge Intervals (Array; Sort)
- CocoaPods did not set the base configuration of your project 问题解决方式
- PLSQL Developer新手使用教程(图文教程)
- 转载:Candy? 在线性时间内求出素数与欧拉函数
- BZOJ4998 星球联盟(LCT+双连通分量+并查集)
- js Object.defineProperty 使用