当前位置: 技术问答>java相关
一个简单的java.util.Vector类函数使用问题
来源: 互联网 发布时间:2015-01-11
本文导语: 定义一个java.util.Vector类,Vector v;v.addElement(new Integer(8)); int i=v.elementAt(0);编译说类型错误,why? | 或 import java.awt.*; import java.awt.event.*; import java.util.Vector; public class MyApp //extends Frame { public M...
定义一个java.util.Vector类,Vector v;v.addElement(new Integer(8));
int i=v.elementAt(0);编译说类型错误,why?
int i=v.elementAt(0);编译说类型错误,why?
|
或
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
public class MyApp //extends Frame
{
public MyApp()
{
}
public static void main(String args[])
{
System.out.println("Starting App");
MyApp f = new MyApp();
Vector v = new Vector();
v.addElement(new Integer(8));
int i = ((Integer)v.elementAt(0)).intValue();
System.out.println(i);
System.exit(0);
}
}
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
public class MyApp //extends Frame
{
public MyApp()
{
}
public static void main(String args[])
{
System.out.println("Starting App");
MyApp f = new MyApp();
Vector v = new Vector();
v.addElement(new Integer(8));
int i = ((Integer)v.elementAt(0)).intValue();
System.out.println(i);
System.exit(0);
}
}