java溢出程序异常

dandanlan789 2009-10-24 11:08:57
这个程序有点异常,请大师指导下。。。
public class Caesar {
public static void main(String args[]) throws Exception {
String s = args[0];
int key = Integer.parseInt(args[1]);
String es = "";
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c > 'a' && c <= 'z') {
c += key % 26;
if (c < 'a')
c += 26;
if (c > 'z')
c -= 26;
}
else if (c >= 'A' && c <= 'Z') {
c += key % 26;
if (c < 'A')
c += 26;
if (c > 'Z')
c -= 26;
}
es += c;
}
System.out.println(es);
// TODO Auto-generated method stub

}

}
错误提示是:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Caesar.main(Caesar.java:3)
...全文
43 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dandanlan789 2010-10-22
  • 打赏
  • 举报
回复
哦 ,谢谢你了。。
rookie001 2009-10-24
  • 打赏
  • 举报
回复
数组越界嘛
注意输入参数的长度

58,441

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧