On Jul 14, 7:51 pm, Alex <[email protected]> wrote:

>   while (class1.getSuperclass() != null){ 
>     String child = class1.getName();
>     String parent = class1.getSuperclass().getName();
>     System.out.println("  " + child + " class is a child class of " + parent);
>     class1 = class1.getSuperclass();
>    }
>  
> I have a question about this while loop.  The expression is place in the ().  
> But at the end the expression is placed into a variable.  How is the loop 
> being incremented? 
A loop is not necessarily something which should be incremented. In
particular, while loops are often used to test that a particular
condition remains true (or false) during the looping.
This is the case here: as long a there is a superclass for the class
being examined continues the loop. And at the end of the loop you
change the class being examined with its superclass. Hence you go up
the hierarchy.

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