0
votes
0answers
56 views

Finding plateau in Java Array [migrated]

I having a really hard time finding a plateau within an array. What I'm looking for is length and location of the longest sequence of equal values where the numbers on both sides are smaller. Now I ...
0
votes
0answers
53 views

Where should I declare variables used in for-loops in Java for maximum efficiency? [duplicate]

I'm talking hypothetically but I'll use an example of what I worked on in a programming class a while ago. There's a better way to actually perform the operation, but that's not the point. An example ...
0
votes
0answers
3 views

Number Patterns using loops in Java [migrated]

I have been trying different variations of for loops and have no clue how to make these patterns: Pattern 1 54321 5432 543 54 5 Pattern 2 1 12 123 1234 12345 Pattern 3 12345 2345 ...
2
votes
2answers
129 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 ...
1
vote
3answers
281 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 ...
1
vote
8answers
772 views

Why does the instruction “do” require a “while”?

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 ...
16
votes
4answers
6k 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 went home and looked up the feature as I didn't know ...
7
votes
3answers
2k 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 ...