Results 1 to 5 of 5
- 05-29-2008, 01:05 AM #1
[SOLVED] Location of Object Declaration
I'm have a superclass(which is a driver class) that has a method in it which calls a method in the class's subclass. Since this method is the only one that uses this object, should i declare my object in the method? or should i declare it at the start at the program with the fields? Thanks in advance. (p.s. i'm not very good at OOP yet):D
Last edited by JT4NK3D; 05-29-2008 at 02:01 AM. Reason: clearing it up
- 05-29-2008, 02:51 AM #2
You may declare it there if that instance should also be used in the next processing....
freedom exists in the world of ideas
- 05-29-2008, 04:14 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If you are use it inside a single method best place is to use it is, on the same method. That's fine. In that case you don't need to hold the memory for that object when it is not used in other methods. And also you can do it in a single line. I really like to use as much as possible, less number of lines.
- 05-29-2008, 10:13 PM #4
Ok thanks I will declare the object inside the method.
You just got T4NK3D!
Adonrcicg to rcesraeh the haumn mnid is clbapae of rdanieg tihs. -Jvaa Sun Moricyssemts-
- 05-30-2008, 03:45 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yep. That's the best option I can see according to your requirement. Mainly those action we should take to have much secure much safer end product.
Similar Threads
-
Declaration
By asifahmed in forum New To JavaReplies: 1Last Post: 04-05-2008, 05:38 AM -
JSP Declaration Directive
By Java Tip in forum Java TipReplies: 0Last Post: 12-10-2007, 05:42 PM -
JFileChooser remember the location
By Mr tuition in forum AWT / SwingReplies: 3Last Post: 12-08-2007, 05:17 PM -
how to get the location of some button
By mary in forum Java 2DReplies: 2Last Post: 08-05-2007, 04:02 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks