当前位置:  技术问答>java相关

请帮帮我~

    来源: 互联网  发布时间:2015-06-28

    本文导语:  /**  * This class can take a variable number of parameters on the command  * line. Program execution begins with the main() method. The class  * constructor is not invoked unless an object of type 'Class1'  * created in the main() method.  */...

/** 
* This class can take a variable number of parameters on the command 
* line. Program execution begins with the main() method. The class 
* constructor is not invoked unless an object of type 'Class1' 
* created in the main() method. 
*/ 
public class Class1 

/** 
* The main entry point for the application. 

* @param args Array of parameters passed to the application 
* via the command line. 
*/ 
public static void main (String[] args) 

int a=10,b=20; 
char c; 
System.out.println("input number+char+number:"); 
a=System.in.read(); 
c=System.in.read(); 
b=System.in.read(); 
switch(c) 

case'+':System.out.println(a+b);break; 
case'-':System.out.println(a-b);break; 
case'*':System.out.println(a*b);break; 
case'/':System.out.println(a/b);break; 


}
请问错在哪?

|
System.in.read()
是要抛出IOException的,你应该捕获并处理这个异常。

你最后把出错信息贴上来吧,这样大家能看得清楚一点。

|
a=System.in.read(); 
c=System.in.read(); 
~~~~~~~~~~~~~~~~~~~~~~~~~`c = (char)System.in.read();
b=System.in.read();  

|
该用try捕获IOException。
System.in.read()返回为int型,要转换。

|
try
{
   ........;
}
catch(IOException e)
{
   e.printStackTrace();
}

    
 
 

您可能感兴趣的文章:

 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • 【有谁能帮帮我】...Liunx上网的乱码问题,查了很多资料还是没有解决,帮帮我呀,好郁闷。
  • 帮帮忙!SCO OpenServer 5.0.5 的root用户口令丢了,怎么找回来啊,帮帮忙!!!!!!
  • 非常感谢,快帮帮我
  • 有谁会Linux下的网络编程,请帮帮我,谢谢!
  • 关于安装ISDN的问题,大侠们帮帮我啊
  • 谁知teleport pto v1.29.1590的注册码,帮帮忙。马上结分
  • 哪里有Intel平台的Solaris 8 下载?? (很急,大家帮帮我!!!)
  • 各位大哥帮帮忙。谁知道怎么加可用分?
  • 请各位帮帮我,一个简单问题
  • 我的Redhat和Mandrake都装不了,帮帮我
  • jb中配置mysql的问题??急啊,帮帮我啊!
  • 一些奇怪的现象,帮帮我
  • 该死的中文显示问题,帮帮忙
  • 帮帮我!谁有jdk和jbuilder。现在急用
  • 如何获得string中某特定第二个字符,请帮帮忙!
  • 关于聊天室的问题,请大家帮帮忙,一定给分
  • 帮帮忙!!!!我的RH8装不进去!!!
  • 帮帮我!
  • 急!大家帮帮忙!有哪些视频点播系统能在在LINUX下安装以及怎样安装!
  • 急!大家帮帮忙!有什么视频点播系统能在LINUX下安装,以及怎样安装!!


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3