# \_parent equivalent in Java?

**URL:** <https://forum.kirupa.com/t/-parent-equivalent-in-java/184777>\
**Category:** random\
**Created:** [April 7, 2006, 5:53pm UTC](https://forum.kirupa.com/t/-parent-equivalent-in-java/184777 "2006-04-07T17:53:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yeldarb](https://avatars.discourse-cdn.com/v4/letter/y/51bf81/32.png) [@Yeldarb](https://forum.kirupa.com/u/Yeldarb)\
**Post date:** [April 7, 2006, 5:53pm UTC](https://forum.kirupa.com/t/-parent-equivalent-in-java/184777/1 "2006-04-07T17:53:02Z")

</div>

Wasn’t sure where to put this (maybe Computers & Games would have been better?)

But basically what I’m looking for is a way to access an variable in and object in the object that’s the parent of the class I’m in.

In flash I’d do something like  
\_parent.myObject.whatever

But I have no idea how to do this in Java. Any ideas?

Rephrased:  
I’ve got a main object that creates two other objects, from within a method in one of the objects, I want to check the state of a variable in the other object that the main object created.

---

<div class="post-metadata">

**Author:** ![MTsoul](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@MTsoul](https://forum.kirupa.com/u/MTsoul)\
**Post date:** [April 7, 2006, 6:20pm UTC](https://forum.kirupa.com/t/-parent-equivalent-in-java/184777/2 "2006-04-07T18:20:42Z")

</div>

super.

---

<div class="post-metadata">

**Author:** ![expensive\_pen](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/expensive_pen/32/554_2.png) [@expensive\_pen](https://forum.kirupa.com/u/expensive_pen)\
**Post date:** [April 7, 2006, 6:25pm UTC](https://forum.kirupa.com/t/-parent-equivalent-in-java/184777/3 "2006-04-07T18:25:06Z")

</div>

super and parent are very different  
actionscript’s super and java’s super are the same thing

---

<div class="post-metadata">

**Author:** ![Stratification](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stratification](https://forum.kirupa.com/u/Stratification)\
**Post date:** [April 7, 2006, 6:30pm UTC](https://forum.kirupa.com/t/-parent-equivalent-in-java/184777/4 "2006-04-07T18:30:17Z")

</div>

I’m not sure there’s an equivalent (though my Java is a little rusty). I’d just pass a reference to the parent object in the constructor of the child, then you’ll have the reference you want.

---

<div class="post-metadata">

**Author:** ![Yeldarb](https://avatars.discourse-cdn.com/v4/letter/y/51bf81/32.png) [@Yeldarb](https://forum.kirupa.com/u/Yeldarb)\
**Post date:** [April 8, 2006, 6:07am UTC](https://forum.kirupa.com/t/-parent-equivalent-in-java/184777/5 "2006-04-08T06:07:13Z")

</div>

Wow, I can’t believe I didn’t think of passing it as a parameter. Thanks guys, I’ll try it next Wednesday when I go back to school and let you know how it turns out.

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [April 8, 2006, 6:41am UTC](https://forum.kirupa.com/t/-parent-equivalent-in-java/184777/6 "2006-04-08T06:41:37Z")

</div>

You can also use dot notation to access nested data from the passed in object :}
