Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dot Syntax for navigating classes?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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="";
}
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
How does this question differ from the earlier one you never returned to?
https://coderanch.com/t/529886/java/java/Data-Structure

Oh, and you didn't return to this one either, not even to SayThanks.
https://coderanch.com/t/527777/java/java/Method-other-class-as-if
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Darryl Burke wrote:How does this question differ from the earlier one you never returned to?
https://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