aspose file tools*
The moose likes Beginning Java and the fly likes Compare CLI arguments with a string value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compare CLI arguments with a string value" Watch "Compare CLI arguments with a string value" New topic
Author

Compare CLI arguments with a string value

Charles Mulloy
Ranch Hand

Joined: Oct 25, 2009
Posts: 30


I tried something similar to the above code. When I test it...



it will repeat what you told it to test but the if statement is not coming up true. How did I mess up this time?

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

It's a very common mistake for new Java programmers. You need to compare objects (including Strings) with .equals():

args[0].equals(find)

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36563
    
  16
And please avoid unexplained abbreviations like "CLI"; it is not obvious at first reading what they mean.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compare CLI arguments with a string value
 
Similar Threads
interface doubt
How to access Inner Anonymous Class
Is there a way to instantiate anonymous inner class?
Constructor in Anonymous inner class
String side effect & how to overcome