Hi Kc

In order to println(something), it must first compute the "something", then to print it. When computing "person1.getName() = " + ... + person1.computeTotalWelth() + ..., it calls the method computeTotalWelth() who just prints 3000. Once the computation is don, it prints the rest. So 30000 is printed in advance.

Hope it helps
mihai

kc a écrit :
Hi,

I notice the example code produce this output:
30000
person1.getName() = Sang Shin, person1.computeTotalWealth() = 30000,
person1.measureIntelligence() = 50
30000
personinterface1.getName() = Sang Shin,
personinterface1.computeTotalWealth() = 30000

looking at the code, I can't figure out why 30000 is printer as first
line:

        System.out.println("person1.getName() = " + person1.getName()
+ "," +
                " person1.computeTotalWealth() = " +
person1.computeTotalWealth() + "," +
                " person1.measureIntelligence() = " +
person1.measureIntelligence(person1.getName()));

        System.out.println("personinterface1.getName() = " +
personinterface1.getName() + "," +
                " personinterface1.computeTotalWealth() = " +
personinterface1.computeTotalWealth());



which i believe the 30000 come from the println() statement in
computeTotalWealth(), just why it appear as first?

    public int computeTotalWealth(){
        System.out.println((cashSaving + retirementFund));;
        return (cashSaving + retirementFund);
    }

Regards
KC


--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to