类属性不能写在try{}catch(){}里面
时间:2014-05-02 15:23:23
收藏:0
阅读:395
public class cal{
public static void main(String[] args){
calculator
ca=new calculator();
byte[] first=new byte[4];byte[] second=new
byte[4];
System.out.println("请输入first");
try{
System.in.read(first);
}
catch(Exception
e){e.toString();}
String f=new
String(first);
System.out.println("请输入second");
try{
System.in.read(second);
}
catch(Exception
e){e.toString();}
String s=new
String(second);
System.out.print(f+","+s);
}
}
类属性不能写在try{}catch(){}里面,里面的只是临时的,try块结束就没有了,比如f和s要在try{}catch(){}外面定义才能打印
评论(0)