• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

return type of Object

 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic