Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

Dot Syntax for navigating classes?

 
Tye Solan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
Is there away to make

Root Workspace=new Root();
Animal Cow=new Animal();
//Parent Cow to workspace
Workspace.Cow.sound="Moo";
Workspace.Cow.color="White, black spots";

where Root and Cow are blank classes with a few properties.
So how do I parent Cow to Root? I think it has to do with super classes or something?

class Root
{

}

class Animal
{
String sound="";
String color="";
}
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Report post to moderator
Yes, it has something to do with super classes or something. If you want Root to be a super class (parent) of Animal then you define Animal as:

If you want Animal to be a parent of Root then you define Root as:
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Report post to moderator
How does this question differ from the earlier one you never returned to?
http://www.coderanch.com/t/529886/java/java/Data-Structure

Oh, and you didn't return to this one either, not even to SayThanks.
http://www.coderanch.com/t/527777/java/java/Method-other-class-as-if
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Report post to moderator
Darryl Burke wrote:How does this question differ from the earlier one you never returned to?
http://www.coderanch.com/t/529886/java/java/Data-Structure . . .
Agree. We only allow One Thread Per Question, so I am closing this thread..
 
    Bookmark Topic Watch Topic
  • New Topic