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
Sheriff
Joined: Jul 22, 2000
Posts: 9033
10
posted
0
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
James Chegwidden
Author
Ranch Hand
Joined: Oct 06, 2002
Posts: 201
posted
0
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>
Younes Essouabni
Ranch Hand
Joined: Jan 13, 2002
Posts: 479
posted
0
If your first condition evaluate to true, the "else" won't be evaluated.
Younes
By constantly trying one ends up succeeding. Thus: the more one fails the more one has a chance to succeed.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.