⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toarray.java

📁 电子工业出版社出版的《java2应用开发指南》配套光盘源代码
💻 JAVA
字号:
import java.util.*;
class ToArray 
{
    public static void main(String[] args) 
{
        Vector v = new Vector(Arrays.asList(new String[]{"dog", null}));
        Object[] objs = v.toArray();
        print(objs);
        // If we passed in a string array, we can cast
        // the result to a string array.
        String[] strings = (String[])v.toArray(new String[0]);
        print(strings);
        // Try adding something other than a string to the vector.
        v.add(new Integer(0));
        print( v.toArray() ); 
        // The Integer object can not be stored in the string array.
        //print( v.toArray(new String[0]) ); 
    }
    static void print(Object[] arr) 
{
        System.out.println(Arrays.asList(arr));
    }
}

⌨️ 快捷键说明

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