• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic