| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1443 人关注过本帖
标题:[求助]请问下面这个程序怎么了
取消只看楼主 加入收藏
lwj19872002
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-8-13
收藏
 问题点数:0 回复次数:11 
[求助]请问下面这个程序怎么了

import java.io.*;
public class testinput {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int in=0;
try{
in=System.in.read();
}catch(IOException e){e.getStackTrace();}
System.out.println(in);

}

}
编译能过!运行有问题!!

搜索更多相关主题的帖子: void public import method 
2007-08-17 23:45
lwj19872002
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-8-13
收藏
得分:0 

可是我在我机子上面运行了有错啊!!!!
高手看看啊!!

2007-08-18 09:21
lwj19872002
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-8-13
收藏
得分:0 

package test_01;

import java.util.*;
import java.io.*;
class testver
{
public static void main(String[] args)
{
Vector<String> ver=new Vector<String>(5,1);
ver.add(0," lwj");
ver.add(1, "lwk");
ver.add(2, "lwl");
ver.add(3, "lwh");
ver.add(4, "lwu");
int count=ver.size();
System.out.println("This is a vector!\nThere are "+count+"members:");
System.out.println("NO. Element");
for(int i=0;i<count;i++)
{
System.out.println(" "+i+" "+ver.get(i));
}
System.out.println("You can input <1> or <2> to choose:");
System.out.println("<1>:Add a new element!");
System.out.println("<2>:Delet a element!\n<3>:To viewer all of them!");
System.out.println("<4>:To exit!");
System.out.println("Please choose:");
int j=0;
try {j=System.in.read()-'0';}catch(IOException e){e.getStackTrace();}
while(j==1||j==2||j==3)
{
switch(j)
{
case 1:add(ver);break;
case 2:delet(ver);break;
case 3:vew(ver);break;
}
System.out.println("Please choose again!");
try {j=System.in.read()-'0';}catch(IOException e){e.getStackTrace();}
}
}
public static void add(Vector<String> ver)
{
DataInputStream din=new DataInputStream(System.in);
BufferedInputStream buf=new BufferedInputStream(din);
System.out.println("Please input what you want to add:");
String str;
byte[] in=new byte[100];
try{
buf.read(in);
}catch(IOException e){e.getStackTrace();}
str=in.toString();
ver.addElement(str);
System.out.println("Successed!");
try{
din.close();
buf.close();
}catch(IOException e){e.getStackTrace();}
}
public static void delet(Vector<String> ver)
{
System.out.println("Please input the index of the element you want to delet!");
int index=0;
try{
index=System.in.read();
ver.remove(index);
}catch(IOException e){e.getStackTrace();}
System.out.println("Successed!!");
}
public static void vew(Vector<String> ver)
{
System.out.println("The all elements are:");
System.out.println("NO. Element");
for(int i=0;i<ver.size();i++)
{
System.out.println(" "+ i+" "+ver.get(i));
}
}
}

2007-08-18 09:29
lwj19872002
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-8-13
收藏
得分:0 

原程序是这有样的1

2007-08-18 09:29
lwj19872002
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-8-13
收藏
得分:0 

那要 输入 怎么用》?

2007-08-18 10:36
lwj19872002
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-8-13
收藏
得分:0 
哦!
谢了!
我去试试!
2007-08-18 10:57
lwj19872002
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-8-13
收藏
得分:0 
那个循环那 怎么该啊!》
2007-08-18 11:01
lwj19872002
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-8-13
收藏
得分:0 
他 好象没有执行try{
buf.read(in);
}catch(IOException e){e.getStackTrace();}//

就跳过去了!!!!
2007-08-18 11:05
lwj19872002
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-8-13
收藏
得分:0 
可是 还是有问题啊!
输入3执行后没法再执行了!
2007-08-18 13:15
lwj19872002
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2007-8-13
收藏
得分:0 
  想知道为什么?
2007-08-18 13:56
快速回复:[求助]请问下面这个程序怎么了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023347 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved