File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "return type of Object" Watch "return type of Object" New topic
Author

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
Sheriff

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
sscce.org
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?

Layne


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: return type of Object