zoukankan      html  css  js  c++  java
  • 容器Collection_2

    import java.util.*;
    
    class Name
    {
        private String firstName,lastName;
        
        public String getFirstName() {
            return firstName;
        }
    
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }
    
        public String getLastName() {
            return lastName;
        }
    
        public void setLastName(String lastName) {
            this.lastName = lastName;
        }
        public Name(String firstName,String lastName)
        {
            this.firstName=firstName;
            this.lastName=lastName;        
        }
        public boolean equals(Object obj)
        {
            if (obj instanceof Name)
            {
                Name name=(Name)obj;
                return (firstName.equals(name.firstName)) && (lastName.equals(name.lastName));            
            }
            
            return super.equals(obj);
        }
        public int hashCode()
        {
            return firstName.hashCode();
        }
        public String toString() {  return firstName + " " + lastName;  }    
        
    }
    
    
    
    public class testmy1 {
        
        public static void main(String[] args) 
        {
            Collection c = new HashSet();
            c.add("hello");
            c.add(new Name("f1","l1"));
            c.add(new Integer(100));
            c.remove("hello"); 
            c.remove(new Integer(100));
            System.out.println
                      (c.remove(new Name("f1","l1")));
            System.out.println(c);
        }
    
    }
  • 相关阅读:
    2、消失的路由,源码的解析基础
    1、v1 与 v2的比较
    uwp 之后台音频
    uwp 之多媒体开发
    UWP 动画之路径
    uwp 动画之圆的放大与缩小
    uwp 中的动画
    C# 输入法
    uwp 之资源的访问
    uwp 之吐司 toast
  • 原文地址:https://www.cnblogs.com/delphione/p/3000950.html
Copyright © 2011-2022 走看看