我目前正在开发一个 Java 程序,它接受一个人输入的参数(我想出了那部分),然后将其添加到一个字符串中,然后将其发送给另一个人。但是,我坚持这一部分,其中第一个参数不包含在消息中。我最初是想到的if (!arg.equals(args[0])){}
,但是在消息中再次提到第一个参数的情况下,它也会从消息中删除它。我如何让它删除第一个参数而不删除任何其他完全一样的参数?
我现在的代码:
if (args.length<=0){
sender.sendMessage(ChatColor.RED + "No player specified.");
} else {
if (args.length==1){
sender.sendMessage(ChatColor.RED + "No message specified");
} else {
String message = "";
for (String arg : args){
if (!arg.equals(args[0])){
}
}
}
}