• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

main method argument passing problem

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need to compare main method argument comparison but I am failed to do so... here is my simple prog

and output is
Apple
I am providing "Apple" argument, It does print Apple but the comparison fails and I dont get "HI" output. whats wrong here?
 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go back and review Java basic instance variables declaration and other Java basic syntax. There are a lot of problems on your code so, it won't work.


 
Rana Asif
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks tommy for reply, can you please explain a little bit...
 
Rana Asif
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tommy Delson wrote:Go back and review Java basic instance variables declaration and other Java basic syntax. There are a lot of problems on your code so, it won't work.



I pass "Apple" argument to main method, so it should return true for (arg[0]=="Apple") but it doesn't.
 
Ranch Hand
Posts: 37
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rana, Java String always brings us lots of surprises. There's a thread on this issue: http://stackoverflow.com/questions/1903094/java-strings-and-stringpool
 
Rana Asif
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry my bad, needed to use equals() method... Thanks Jeffrey Tian for tip.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic