witam,
napisalem maly program do losowego tworzenia liczb. w miare wykonywania, program zmniejsza pule dostepnych liczb. chciblym zmierzyc ile czasu program dzialal i tu wyskakuje mi blad range@9fef6f
czy moglbym ktos powiedziec co jest nie tak?
z gory dzieki
pozdrawiam
kod do mierzenia czasu spoko wzialem stad:
http://www.lykkenborg.no/java/2005/03/how-to-measure-execution-time.html
a moj kod to:
import javax.swing.JOptionPane;
import java.util.*;
public class range {
private long start, stop;
public void start() {
start = System.currentTimeMillis(); // start timing
}
public void stop() {
stop = System.currentTimeMillis(); // stop timing
}
public long Time() {
return stop - start;
}
public String end() {
return "It took " + Long.toString(Time())+" seconds."; // print execution time
}
public static void main(String[] args) {
range stopwatch = new range();
stopwatch.start();
int range=0, move=0, numConnections;
String nodes=JOptionPane.showInputDialog("How many nodes network has?");
int nodes_number=Integer.parseInt(nodes);
stopwatch.start();
for (int i=0; i<nodes_number; i++ ){
Random rnd = new Random();
numConnections = rnd.nextInt(nodes_number - range) + move;
range++;
move++;
System.out.println("Round " + i);
System.out.println("Number " + numConnections);
};
stopwatch.stop();
System.out.println(stopwatch);
}
}