Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Programmer Certification (OCPJP)
Local method
Sudhakar Krishnamurthy
Ranch Hand
Posts: 76
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello:
Is it possible to have a local method on same lines of a method-local inner class, i.e. a method inside a method, if so how does it look? examples will be appreciated.
Thanx,
-S
Billybob Marshall
Ranch Hand
Posts: 202
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Nope
Vad Fogel
Ranch Hand
Posts: 504
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Methods can only be enclosed in classes or interfaces.
Stephen Galbraith
Ranch Hand
Posts: 90
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Not directly (as has been said already),
but you can define anonymous inner classes, that can "look" similiar to what I think you're talking about....
public void myMethod(){ JButton myButton = new JButton("junk"); myButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ // somethig happens in here } }); }
SCJP 1.4, SCJD, SCWCD 1.4
What's that smell? Hey, sniff this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
IS CONCTRUCTOR IS A METHOD
final local variable question
Threads Q
Did implicit objects are instance variables or local variables in _jspService
Method local Inner Class
More...