java第9天代码(集合类)
/**********Customer .java begin***********/
import java.util.HashSet;
import java.util.Set;
/**
* 如果两个Customer对象nama属性和age属性相同,那么这两个Customer对象相等。
* @author Administrator
*
*/
public class Customer {
private String name;
private int age;
public String getName() {
return name;
}
public int getAge() {
return age;
}
public void setName(String name) {
this.name = name;
}
public void setAge(int age) {
this.age = age;
}
public Customer(String name, int age) {
super();
this.name = name;
this.age = age;
}
public Customer(){}
/**
* 如果Customer类覆盖了Object类中的equals方法,但没有覆盖Object中的HashCode方法,
* 就会导致当Customer1.equals.(Customer2)为true时,而Customer1和Customer2的哈
* 希码不一定一样,就会使HashSet无法工作。
*/
@Override
public boolean equals(Object obj) {
if((obj instanceof Customer)){
Customer other=(Customer) obj;
if(this.name.equals(other.getName()) && this.age==other.getAge()) {
return true;
}
}
return false;
}
/**
* 为了保证HashSet的正常工作,如果Customer类覆盖了equals方法,同时也应该去覆盖hashCode
* 方法,并且保证两个相等对象的哈希码也是一样。
*/
// @Override
public int hashCode() {
int result;
result=(name==null?0:name.hashCode());
result=result+age;
return result;
}
public static void main(String args[]){
Set set=new HashSet();
&nb
相关文档:
JAVA\JSP上传组件
本人只有这个水准,会的请指点,不会的,可以拿源码
大概的要求:
单独负责上传的类,只用iframe调用其它的类不用调用
上传预览
单个文件上传与多个文件都支付
多个文件上传需要在iframe父级页面传参,也就是开关鸟
预览时可以删除原文件和预览的(多个文件)某个节点
文件类型的在iframe定义
禁止用 ......
JAVA学习的一些重点
1. Java语言基础
谈到Java语言基础学习的书籍,大家肯定会推荐Bruce Eckel的《Thinking in Java》。它是一本写的相当深刻的技术书籍,Java语言基础部分基本没有其它任何一本书可以超越它。该书的作者Bruce Eckel在网络上被称为天才的投机者,作者的《Thinking in C++》在1995年曾获SoftwareDev ......
oracle
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_S ......
深刻理解Java编程的7个例子 佟强 2009年11月7日 http://blog.csdn.net/microtong
1. 阅读下列代码回答问题(第一个Java程序,理解PATH和CLASSPATH,学会使用javac和java命令)
view plaincopy to clipboardprint?
package cn.edu.uibe;
public class HelloWorld {
......