This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes return type of Object 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 "return type of Object" Watch "return type of Object" New topic

return type of Object

Maureen Charlton
Ranch Hand

Joined: Oct 04, 2004
Posts: 218
I am focusing on Local class and have the following code:

In my course notes it states that 'The method has a return type of Object'.

Is this referring to Object being a String?
Abdulla Mamuwala
Ranch Hand

Joined: Jan 09, 2004
Posts: 225
Hi Maureen,

String is a type of Object.
In your code the public method createTheInner() is defined to return an Object, but is returning nothing. What I mean is shown in the code below in bold.
marc weber

Joined: Aug 31, 2004
Posts: 11343

I'm guessing the assignment is to define an inner class, and demonstrate that the inner class has access to private members of the outer class. It also looks like the outer class should include a method that returns an instance of the inner class as an Object. Is this correct?

In your code, you're trying to define a method inside of another method. But methods can only be members of classes (or interfaces). So you want to put a class definition inside your class, and then keep your methods as members of those classes (not other methods). Does that make sense?

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Maureen Charlton:
In my course notes it states that 'The method has a return type of Object'.

Is this referring to Object being a String?

To answer your question directly, look at this line in the code:

Your notes are referring to the word "Object" here.

Also, as noted above, there are other problems with the code you posted. Have you tried to compile it?


Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: return type of Object
Similar Threads
Overriden Vs Re-Define
printing and returning arrays
Why this is giving error
Getting Incompatible Types java.lang.String
casting interface to object.