C:\Java\EigeneJavaProgramme>java ZombieStomp Killer Of Giants Symphony of Destruction If str = „markl“ then (str instanceof String) is true AND (str instanceof Object) is true. Why doesn’t it print: Killer Of Giants I Shot the Sheriff Symphony of Destruction
Marilyn de Queiroz
Joined: Jul 22, 2000
If str = „markl“ then (str instanceof String) is true AND (str instanceof Object) is true. Why doesn’t it print:
Killer Of Giants I Shot the Sheriff Symphony of Destruction
because of the 'else'. Read --
if str is an instance of string => print Killer Of Giants
or else if string is not an instance of string but is an instance of Object => print I Shot the Sheriff
then always print Symphony of Destruction
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joined: Oct 06, 2002
Is there any particular reason you added the final keyword in the main method header?
Mr. C<br /> <br />Author and Instructor<br />My book:<br /><a href="http://www.aw-bc.com/catalog/academic/product/0,1144,1576761614,00.html" target="_blank" rel="nofollow">http://www.aw-bc.com/catalog/academic/product/0,1144,1576761614,00.html</a>
Joined: Jan 13, 2002
If your first condition evaluate to true, the "else" won't be evaluated.
By constantly trying one ends up succeeding. Thus: the more one fails the more one has a chance to succeed.