Can we create nested methods? (method within onther method, both returning data)
Nested Methods
Collapse
X
-
No you can not (the syntax of Java forbids it). You can however create a classOriginally posted by gmioannouCan we create nested methods? (method within onther method, both returning data)
local to a method and populate that inner class with methods but the use of it is
little if all you want are nested methods. Why do you want them anyway?
kind regards,
Jos -
Sure you can do that but those aren't nested methods (they don't exist in Java).Originally posted by gmioannouI had to create a function to return some value. I assume the practice of the language is to override the method within the subclass and return the value.
kind regards,
JosComment
-
This is the syntax:Originally posted by gmioannouI had to create a function to return some value. I assume the practice of the language is to override the method within the subclass and return the value.
[CODE=Java]class A {
public void method() {...}
}
class B extends A {
@Override
public void method() {...}
}[/CODE]
(The annotation "@Override" is optional (and can only be used in versions >= 5) but documents the override.)
Your description doesn't make me confident that you understand overriding or even that you need to use it. You should better describe your context, your goal and what you are trying to do.Comment
Comment