473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Nested Methods

Can we create nested methods? (method within onther method, both returning data)
Dec 11 '07 #1
4 2097
JosAH
11,448 Expert 8TB
Can we create nested methods? (method within onther method, both returning data)
No you can not (the syntax of Java forbids it). You can however create a class
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
Dec 11 '07 #2
I 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.
Dec 11 '07 #3
JosAH
11,448 Expert 8TB
I 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.
Sure you can do that but those aren't nested methods (they don't exist in Java).

kind regards,

Jos
Dec 11 '07 #4
BigDaddyLH
1,216 Expert 1GB
I 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.
This is the syntax:

Expand|Select|Wrap|Line Numbers
  1. class A {
  2.     public void method() {...}
  3. }
  4.  
  5. class B extends A {
  6.     @Override
  7.     public void method() {...}
  8. }
(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.
Dec 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Edward Povazan | last post by:
Hello, I have a method like the following. public void resetSessions() { // All the following are private, used to implement resetSessions() insertNullSessions(); applyUserSession();...
3
by: Nils Grimsmo | last post by:
hi, i'm having some trouble nesting functions. consider the following: def h(): x = 1 def g(): print x # ok, x is taken from h g()
6
by: Andy Baker | last post by:
Hi there, I'm learning Python at the moment and trying to grok the thinking behind it's scoping and nesting rules. I was googling for nested functions and found this Guido quote:...
10
by: nobody | last post by:
I just tried to do something and realized I'm not sure of the proper (if there *IS* a proper) way to do it. I'm designing a class with a lot a methods/properties. I would like to group some of...
10
by: nimmi_srivastav | last post by:
Below you will see an example of a nested conditional expression that this colleague of mine loves. He claims that it is more efficient that a multi-level if-else-if structure. Moreover, our...
11
by: C# Learner | last post by:
Is it not possible to declare a nested class in a seperate file from its "parent" class -- i.e. in a similar way to the idea of spreading namespaces over more than one file?
37
by: Tim N. van der Leeuw | last post by:
Hi, The following might be documented somewhere, but it hit me unexpectedly and I couldn't exactly find this in the manual either. Problem is, that I cannot use augmented assignment operators...
5
by: John Kotuby | last post by:
Hi all, After more than a year programming with ASP.NET 2.0 and VB I am still finding it difficult to leave some habits from classic ASP behind. this is particularly true with cross-page posting....
3
by: Cousson, Benoit | last post by:
I don't think so; my original email was mainly a question. I do agree that they are other ways to do what I'm trying to achieve; there are always several ways to solve an issue. Few days ago, I...
9
by: Gabriel Rossetti | last post by:
Hello, I can't get getattr() to return nested functions, I tried this : .... def titi(): .... pass .... f = getattr(toto, "titi") .... print str(f) .... Traceback...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.