*Here are the instructions of this example:*

1. Modify DummyClass.java as shown in Code-5.15 below.  The code fragments
that need to be added are highlighted in bold and blue-colored font.

*
Here is the code as shown in "Code-5.15 Modified DummyClass.java"*

public class DummyClass {

    void mymethod1(){

        // Note that mymethod2() and this.mymethod2() are the same thing.
        String s1 = mymethod2("Sang Shin");
        String s2 = this.mymethod2("Sang Shin");

        System.out.println("s1 = " + s1 + " s2 = " + s2);

        // Pass the current object instance as a parameter
        String s3 = this.mymethod3(this);
        System.out.println("s3 = " + s3);
    }

    String mymethod2(String name){
        return "Hello " + name;
    }

    String mymethod3(Object o1){
        return o1.getClass().getName();
    }
}



*The output says it is supposed to be:*

s1 = Hello Sang Shin s2 = Hello Sang Shin
s3 = DummyClass


*I followed the exercise correctly, but here is my output (which is
different):*

s1 = Hello Sang Shin, s2 = Hello Sang Shin
s3 = mythisreferenceexampleproject.DummyClass




*My question is:
Mine shows the project folder before the class. I mean, it did get the class
name, but it got the package (project folder's) name as well.
Did I do something wrong or is the exercise miss printed?*

Thanks,
Stephen

--~--~---------~--~----~------------~-------~--~----~
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