java数组存储元数怎弄啊?

来源:百度知道 编辑:UC知道 时间:2024/05/15 03:05:30
我定义了个数组,然后 我分几次向其中输入内容,怎样可一将这些内容全存到该数组中呢?
也就是多次输入的直放到一个数组中 是2维数组

funny..你自己想个顺序,往二维数组里面存不就好了么?可以事先规定一个足够大的N,初始化的时候就类似String[][] str = new String[N][N];
有什么问题么?..
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Temp {

public static void main(String[] args) throws IOException {
String[] str = new String[10];
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int i = 0;
while(i<10){
String s = br.readLine();
if(!s.equals("-1")){
System.out.println("|"+s+"|");
str[i++] = s;
}
else{
System.out.println("end");
break;
}
}
for(int j=0;j<str.length&&str[j]!=null;j++){
System.out.println(str[j]);
}

}
}

for循环嵌套for循环 活用递归

我也学习下...