在java中比较args值和字符串
我正在试用这个代码在java中比较args值和字符串,java,Java,我正在试用这个代码 catch (Exception e) { String s="-help"; String s1="[-help]"; if(s.equals(args) || s1.equals(args)) { System.out.println("hello"); } else { log.info(e.getMessage()); HelpFormatter formatt
catch (Exception e) {
String s="-help";
String s1="[-help]";
if(s.equals(args) || s1.equals(args))
{
System.out.println("hello");
}
else
{
log.info(e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("AutoLockComponent ", options, true);
}
}
但是每次我试着调试代码时,它总是会阻塞else而不是进入if条件,我的意思是输出是“hello”,但我正在打印log.info消息,有人能帮我吗,非常感谢你的帮助,我还附加了args值的调试器信息图像。
args
是一个数组。不是一串。在特定情况下,您需要args[0]
if(s.equals(args[0]) || s1.equals(args[0]))