compare two strings in java using command line arguments
This question already has an answer here:
"Error: Could not find or load main class CompareString"
Your error message says you couldn't load class "CompareString", but your code says your class name is CompareString s .
Your class name is wrong.
Your error says
Error: Could not find or load main class CompareString
but the name of class is CompareStrings
not CompareString
launch using java CompareStrings
Read this good tutorial on compiling and launching java programs
First of all you are trying to use wrong class, should be CompareStrings
and not CompareString
.
Second, I would recommend using a nice utility lib for handling command line called Cliche from Google Code site
And third, it would be good to check if the given string is null before you call compareToIgnoreCase
on it
上一篇: .jar文件无法在我的Mac上打开
下一篇: 使用命令行参数比较java中的两个字符串