aspose file tools*
The moose likes Beginning Java and the fly likes a command line argument, a comparison, an interesting result Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "a command line argument, a comparison, an interesting result" Watch "a command line argument, a comparison, an interesting result" New topic
Author

a command line argument, a comparison, an interesting result

Carlos Failde
Ranch Hand

Joined: Oct 20, 2000
Posts: 84
The following program compiles

I ran the program with the command "java StringTest /?" at the DOS prompt
The output was:
false
/?
/?
Can someone explain this?
I want to know if a user uses the program with the parameter /?
Asuthosh Borikar
Ranch Hand

Joined: Sep 29, 2000
Posts: 75
Try s.equals("/?") in place of s=="/?".
The "==" operator tests if the two object references point to the same object, which is not true in this case.
String class overrides the "equals" method in the Object class,
to compare the values of the two strings in question and return true if they are the same. It DOES NOT check to see if both the strings point to the same object in memory.
Carlos Failde
Ranch Hand

Joined: Oct 20, 2000
Posts: 84
Ah yes of course. Much thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a command line argument, a comparison, an interesting result