两数相加 public class Main { public static void main(String[] args) { try { // 将参数转换为整数 int num1 = Integer.parseInt(args[0]); int num2 = Integer.parseInt(args[1]); // 计算两个数的和 int sum = num1 + num2; // 输出结果 System.out.println(sum); } catch (NumberFormatException e) { // 如果转换失败,输出错误信息 System.out.println("输入的参数不是有效的整数。"); } } } 两数相减 public class Main { public static void main(String[] args) { try { // 将参数转换为整数 int num1 = Integer.parseInt(args[0]); int num2 = Integer.parseInt(args[1]); // 计算两个数的差 int sum = num1 - num2; // 输出结果 System.out.println(sum); } catch (NumberFormatException e) { // 如果转换失败,输出错误信息 System.out.println("输入的参数不是有效的整数。"); } } } 回文数 public class Main{ public static void main(String[] args){ String str = args[0]; int len = str.length(); String ans = "true"; for(int i=0;i<len/2;++i){ if(str.charAt(i) != str.charAt(len-i-1)){ ans = "false"; break; } } System.out.println(ans); } }