我是Java的新手,我得到了一个像这样的向量: InputStream inputStream; String string; FileOutputStream fileOutputStream; Vector vector = new Vector(); vector.add(inputstream); vector.add(string); vector(fileoutputstream);问题是它们会转换为对象,我如何才能像这样获得所有对象: InputStream inputStream2; String string2; FileOutputStream fileOutputStream2; inputStream2 = vector.get(0); string2 = vector.get(1); fileOutputStream2 = vector.get(2);谢谢
1 回答
芜湖不芜
TA贡献1796条经验 获得超7个赞
Vector是一个泛型类。但是我要问,为什么要在单个向量类中添加InputStream,String和OutputStream对象?
但是,如果必须执行类似的操作,则应按如下所示初始化类:
Vector<Object> vector = new Vector<>();
InputStream inputStream2 = (InputStream) vector.get(0);
String string2 = (String) vector.get(1);
FileOutputStream fileOutputStream2 = (FileOutputStream) vector.get(2);
添加回答
举报
0/150
提交
取消