Tagged Questions
2
votes
2answers
143 views
Is there a difference between declaring variables outside or inside a loop? [closed]
Is there any difference if I were to write something like this:
int row,col;
for(row = 0; row < data.length; row++){
for(col = 0; col < data[row].length;col++){
//do ...
2
votes
1answer
662 views
What is the difference/ advantage of doing double assignment?
Is there any advantage / is it a bad practice in Java to do the below
x = x = 5
I saw it in one of my peers code and I was surprised why he would do double assignment?
Is this something that is ...
14
votes
10answers
3k views
How to write useful Java programs without using mutable variables
I was reading an article about functional programming where the writer states
(take 25 (squares-of (integers)))
Notice that it has no variables. Indeed, it has nothing more than three ...
7
votes
3answers
3k views
Does it make a difference if I declare variables inside or outside a loop in Java? [duplicate]
Possible Duplicate:
Where do you declare variables? The top of a method or when you need them?
Does it make a difference if I declare variables inside or outside a loop in Java?
Is this
...
4
votes
3answers
6k views
What is meant by Scope of a variable?
I think of the scope of a variable as -
"The scope of a particular variable is the range within a program's source code in which that variable is recognized by the compiler".
That statement is ...
8
votes
2answers
7k views
Naming conventions for instance, local and parameter variables
I was discussing with a senior developper coding conventions to apply to our projects (mainly Java/JEE projects). I disagreed with one convention he proposed:
Instance variable names should start ...
7
votes
6answers
1k views
Prefer class members or passing arguments between internal methods?
Suppose within the private portion of a class there is a value which is utilized by multiple private methods. Do people prefer having this defined as a member variable for the class or passing it as ...