intvalue.java
来自「具有代表性的示例,是初学java编程者不错的选择.」· Java 代码 · 共 52 行
JAVA
52 行
/*
* Created on 2005-5-12
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.chapter2;
import java.util.List;
import java.util.ArrayList;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class IntValue {
private int iValue ;
public IntValue ( int iValue){
this.iValue = iValue ;
}
public int getIValue ( ){
return this.iValue ;
}
public boolean equals(Object other){
if ( other instanceof IntValue){
IntValue otherVlaue = (IntValue)other ;
if ( this.iValue == otherVlaue.getIValue()){
return true ;
}
}
return false;
}
public static void main(String[] args) {
List intList1 = new ArrayList();
List intList2 = new ArrayList();
IntValue value1 = new IntValue(99);
IntValue value2 = new IntValue(99);
intList1.add(value1);
intList1.add(value2);
intList2.add(value1);
intList2.add(value2);
System.out.println(value1 == value2);
System.out.println(value1.equals(value2));
System.out.println(intList1.equals(intList2));
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?