Skip to main content

All Questions

Tagged with
-3 votes
1 answer
4k views

Using System.out.println() with loops and arrays [closed]

Is there anyway I can create a loop for System.out.println("...") and reading in the values? For example I wish to do this: System.out.println("Input the Executive's name: "); String eName = ...
gordon sung's user avatar
-10 votes
1 answer
2k views

Java: Why's this For-Loop thousands of times slower?

So I have a simple method I'm calling millions of times a second, and I noticed that it was taking 16% of all processing time!! The offensive routine is as follows: public void placeHolder(){ ...
thebest108's user avatar
6 votes
2 answers
2k views

Is using for loop syntax for a "with(variable)" block an anti-pattern?

I fooled around with for-loops, remembered the with keyword from delphi and came up with following pattern (defined as a live template in IntelliJ IDEA): for ($TYPE$ $VAR$ = $VALUE$; $VAR$ != null; $...
Binkan Salaryman's user avatar
2 votes
2 answers
11k views

Is "continue" and "break" in loops antipattern/bad practice in Java? [duplicate]

I see the main purpose of continue in programming, it can get you out from the rest of loop steps like: while(condition1){ ... code ... if(!condition2){ continue; } ... code ... if(...
CsBalazsHungary's user avatar
2 votes
2 answers
3k 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 ...
user3189506's user avatar
1 vote
3 answers
595 views

How do you avoid looping mistakes? Mistakes that are not detected by systems [closed]

I had this crazy initialisation -- documentList = new ArrayList<Map<String,Integer>>(); which I intended to store a new map everytime in a loop but unfortunately put itself inside the ...
Shashank Sabniveesu's user avatar
0 votes
10 answers
1k views

Why does the instruction "do" require a "while"? [closed]

Since this statement is so common: while (true) (Java) or while (1) (C) or sometimes for (;;) Why is there not a single instruction for this? I could think that an instruction that could do it ...
Niklas Rosencrantz's user avatar
37 votes
6 answers
135k views

Why are nested loops considered bad practice?

My lecturer mentioned today that it was possible to "label" loops in Java so that you could refer to them when dealing with nested loops. So I looked up the feature as I didn't know about it and many ...
Force444's user avatar
  • 643
16 votes
5 answers
41k views

Does it make a difference if I declare variables inside or outside a loop in Java?

Does it make a difference if I declare variables inside or outside a loop in Java? Is this for(int i = 0; i < 1000; i++) { int temp = doSomething(); someMethod(temp); } equal to this (with ...
Puckl's user avatar
  • 1,555