Results 1 to 5 of 5
- 01-12-2013, 04:11 AM #1
Senior Member
- Join Date
- Jan 2013
- Posts
- 137
- Rep Power
- 0
-
Re: Declaring variables: Inside or outside the main method?
The main method should be short as can be and should pretty much function just to set the program going, that's it.
- 01-12-2013, 06:23 AM #3
Senior Member
- Join Date
- Jan 2013
- Posts
- 137
- Rep Power
- 0
- 01-14-2013, 05:20 PM #4
Member
- Join Date
- Jan 2013
- Posts
- 1
- Rep Power
- 0
Re: Declaring variables: Inside or outside the main method?
If the variables you want to declare are ONLY used in the main method then it is good practice to keep them inside that method. However, as Fubarable said earlier, the main method is typically very short.
Last edited by jayamm; 01-14-2013 at 08:42 PM.
- 01-14-2013, 08:33 PM #5
AN21XX
- Join Date
- Mar 2012
- Location
- Munich
- Posts
- 297
- Rep Power
- 2
Re: Declaring variables: Inside or outside the main method?
From your question I do not think you understood the concept of object orientation or even earlier concepts. I think you should read on what it is about and why it is like that. Why and how variables are declared in different scopes and where it makes sense to declare them and where not. Doing a tutorial step by step should help or you may read about what there is here: Variables (The Java™ Tutorials > Learning the Java Language > Language Basics)
I like likes!.gif)
Similar Threads
-
Declaring variables on the fly
By sihyde in forum New To JavaReplies: 2Last Post: 04-20-2012, 02:35 PM -
Question about declaring variables
By salmontres in forum New To JavaReplies: 2Last Post: 12-18-2011, 12:58 AM -
Declaring a method inside a method: Runnable?
By africanhacker in forum New To JavaReplies: 8Last Post: 03-23-2011, 04:30 AM -
Declaring variables
By Flashmatix in forum New To JavaReplies: 12Last Post: 01-20-2009, 03:43 PM -
Declaring global variables
By eva in forum New To JavaReplies: 3Last Post: 12-23-2007, 12:11 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks