首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

excuse me,该如何处理

2012-02-26 
excuse mestaticObject[]get(){Object[]listnewObject[10]inti0System.out.println( pleaseinputpara

excuse me
static   Object[]   get()
{
Object[]   list   =   new   Object[10];
int   i=0;
System.out.println( "please   input   parame ");
do
{
InputStreamReader   isr   =   new   InputStreamReader(System.in);  
BufferedReader   br   =   new   BufferedReader(   isr   );
try   {

list[i]   =   br.readLine();
}   catch   (IOException   e)   {

e.printStackTrace();
    }

}while(list[i]!= "# ");

for(i   =   0;   i <10;   i++)
System.out.println( "list[ "+i+ "]= "+list[i]);

return   list;



}
请问有什么问题啊?运行不成功.


[解决办法]
主要是while (!list[i++].equals( "# "));这里

static Object[] get() {
Object[] list = new Object[10];
int i = 0;
System.out.println( "please input parame ");
do {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
try {

list[i] = br.readLine();
} catch (IOException e) {
e.printStackTrace();
} catch (ArrayIndexOutOfBoundsException e) {
break;
}
} while (!list[i++].equals( "# "));

for (i = 0; i < 10; i++)
System.out.println( "list[ " + i + "]= " + list[i]);
return list;
}
[解决办法]
n错了.
[解决办法]
for( ;i <=n;i++) -> for(; i <n; i++) //数组下标是从0到n-1,当i=n时数组越界了

热点排行
Bad Request.