JAVA怎么实现添加字符串
import java.util.Vector;import java.util.Scanner;
class Test{
public static void main(String args[]){
Scanner reader=new Scanner(System.in);
Vector v=new Vector();
int n=reader.nextInt();
int m=reader.nextInt();
int t=reader.nextInt();
for(int i=0;i<n;i++)
v.addElement(new Integer((int)(Math.random()*m)));
v.addElement("hello world");
//String s=reader.next(args[0]);
//v.addElement(s);
if(t<0||t>n+1)System.out.println("error");
else
v.insertElementAt("A",t);
System.out.println(v.toString());
}
}
随便输入三个数运行结果是这样
3 101 0
[A, 86, 76, 1, hello world]
现在我想把红色代码替换蓝色代码,实现键盘随机输入一个字符串,可是运行错误,请问怎么改呀