Tagged Questions
1
vote
1answer
64 views
High School Java Class: Pong Project External Reviewer
Panelball class:
import java.awt.*;
import java.awt.event.KeyEvent;
import javax.swing.*;
public class Panelball extends JPanel implements Runnable {
private static final long ...
1
vote
0answers
77 views
new md5 algorithm
can you please try my algorithm and give a comment or feedback about it? thank you in advance.. :) this is in java language just copy and paste all of it and run in e.g. netbeans or eclipse thanks
...
1
vote
2answers
53 views
Setting a OnClickListener in a loop
I am trying to set a OnClickListener to a image in a loop. If the params platform is "android" then use market app, instead of default browswer. Is there a better solution to my exception handling or ...
3
votes
1answer
44 views
Code to find the proper index comparing 3 values for max one
I have an algorithm and the idea is to move over an array choosing as index the index of the neighboring cell that has the max value.
I.e.
if array[i + 1][j + 1] has the largest value among the 3 ...
1
vote
2answers
153 views
How to Format Clean Accumulation Code?
I often find myself writing methods in languages such as Java or C++ that are only meant to loop over an array or something similar, accumulate the values, and then return the total. The problem is, ...
4
votes
1answer
198 views
efficient looping procedure to find the longest common substring java
I retrieved 200 tweets using jersey API. I want to find two tweets which have the longest common substring. This is what I have got. tweetList is an ArrayList of Tweet Objects. comapreTweets method ...
2
votes
1answer
96 views
Rewriting nested for loops to give better formatted output
The following is code from a university practical I am doing. It reads in a txt file of twenty clients, whose information is stored in the txt file like this:
Sophia Candappa F 23 00011
As ...
5
votes
5answers
404 views
Looping over a list, checking a boolean and return value
public boolean checkNameStartsWith(List<Foo> foos) {
for (Foo foo : foos) {
if (!(foo.getName().startsWith("bar"))) {
return Boolean.FALSE;
}
}
return ...
1
vote
2answers
63 views
Request for help to tidy up code involving arrays and loops
I posted the following code on here a few days ago:
public class Practical4_Assessed
{
public static void main(String[] args)
{
Random numberGenerator = new Random();
int[] ...
4
votes
2answers
153 views
Understanding the use of for loops as counting loops in homework review [closed]
Newbie here, first time programmer. I have a homework assignment that I am working on. Instructions:
Write an application that allows input of an integer n between 1 and 71, and (using a for or ...
4
votes
1answer
968 views
Java 2d array nested loops
Okay, So I have this method I made that searches a 2d array of user input column length and row length comprised of integers. The method is suppose to find 4 alike numbers in rows, columns, and both ...
4
votes
3answers
389 views
Enhanced for loop
I much prefer the Java enhanced for each loop, but I often find there are certain times where I need to break from a loop, take the following contrived example:
final List<String> strings = new ...
2
votes
2answers
190 views
Java - Object declaration out of while loop
Could you explain to me which code is better (more optimal) and why?
Vesion 1:
while(something){
Runnable task = (Runnable) taskQueue.dequeue();
Throwable ex = null;
...
}
Version 2:
Runnable ...
3
votes
1answer
596 views
Writing to an HttpURLConnection in a loop
I have this method which sends binary data to server. The code works fine, but still, it's structure is kinda stupid: output and input connections are opened like thousands times (depends on data ...
2
votes
3answers
2k views
reorder a list in java
I have three ways of reordering a list (think baseball order) and I am sure you can come up with more. What is a the best way?
For example if input is list is 1,2,3,4 and current is 3 then the ...