java溢出程序异常
这个程序有点异常,请大师指导下。。。
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)