contains.java

来自「java2应用开发指南第一版」· Java 代码 · 共 17 行

JAVA
17
字号
import java.util.*;
class Contains
{
    public static void main(String[] args) 
{
//
     Vector v = new Vector(Arrays.asList(
new Object[]{"dog", null, new Integer(7)}));
        System.out.println( v.contains("dog") );         // true
        System.out.println( v.contains(null) );          // true
        System.out.println( v.contains("pig") );         // false
        // This shows that although the two Integer objects are different,
        // they are considered the same according to their equals() method.
        System.out.println( v.contains(new Integer(7)) );// true
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?