首页 > 题库 > 学历提升 > 自学考试 > 自考本科 > 问答题

阅读程序,请写出该程序的功能。
import java.io.BufferedReader; import java.io.lOException;
import java.io.InputStreamReader;
class MyStringException extends Exception{
public MyStringException(){ super("too long"); }
public MyStringException(String message){ super(message); }
}
public class Test30{
public statie void main(String[] args) throws IOException {
int maxLength= Integer.parseInt(args[0]);
BufferedReader keyboard=new BufferedReader(new
InputStreamReader(System.in));
try{
String input=keyboard.readLine();
if(input.length)<maxLength) System.out.println(input);
else throw new MyStringException();
}catch(MyStringException e){
System.out.println(e.getMessage());
}
}
}


参考答案: 查看答案 查看解析 下载APP畅快刷题

相关知识点试题

相关试卷