Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

return type of Object

 
Maureen Charlton
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic