wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes What is this type of method call?   t.anim.getThis() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is this type of method call?   t.anim.getThis()" Watch "What is this type of method call?   t.anim.getThis()" New topic
Author

What is this type of method call? t.anim.getThis()

John Quach
Ranch Hand

Joined: Sep 28, 2011
Posts: 50
To me, it looks like a method within a method. What is this concept called?


Also, since Object is every class's superclass, is it possible to create an array of Objects that can take in many different types of objects?
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
John Quach wrote:Also, since Object is every class's superclass, is it possible to create an array of Objects that can take in many different types of objects?

This is a completely unrelated question, which really ought to have been posed in a distinct thread. However, the answer is yes. Anything that extends Object can be stored as an element in an Object[] array.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

John Quach wrote:To me, it looks like a method within a method. What is this concept called?

method call in a method is allowed. i think you may get something from here
John Quach wrote:
Also, since Object is every class's superclass, is it possible to create an array of Objects that can take in many different types of objects?

Arrays are co-variants . and array itself is a subclass of java.lang.Object
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

to me it looks like calling a public method of an inner class


SCJP
Visit my download page
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

It's just a simple method call. The rest is just chained references.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37941
    
  22
There may be poor style that you are using identifiers like t, and poor design if anim hasn’t got private access.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

i recognize it now since i have written similar code on occasion. i will bet my last dollar that anim is at least package access. if you have ever created a "child" class passing it a reference to "this" in the constructor, then tried to access a private variable of the "parent" class, the compiler will tell you there are 2 options. make the variable package access or write a get method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is this type of method call? t.anim.getThis()
 
Similar Threads
Collections.sort() does not sort my ArrayList
array conversion
compareTo method
turn string date to number date
High volume data processing question