Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Program execution discrepancies

 
Olakunle Oladipo Oni
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm presenting two sample java code here...I'll appreciate if someone can give me an explanation at getting the expected outcome I believe there's something i need to learn here...

code sample one


I had no problem with compiling this code. I ran it as well. It didn't give any visible error or exception but nothing was printed out which is against my explanation. I supplied the appropriate runtime arguement as indicated in the code yet it ran(as it were) and printed nothing. How can this code print the text indicated?

code sample two


Just like the first sample, this code compliled successfuly. At runtime, i supplied the appropriate arguement to show successful payroll processing but no matter the arguements i supplied i keep getting only "Error...exiting". How do i get around this?


olakunle oni
 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never ever ever use == to compare Strings, use the equals method:
 
Olakunle Oladipo Oni
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate your response. This is the advantage of forums like this. I just saw something i overlooked...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic