このテストを実行しようとしています-計算速度のために-Point
いくつかのメソッドで名前が付けられたこのオブジェクトクラスで。コンストラクターで 3 つの入力/変数を取りますPoint(String, double, double)
。
私はこの考えを持っていますが、コードに入れることができないようです: を使用して A と C の間に乱数を作成し、Math.random
その数を変数に入れ (これらの 3 つの入力のそれぞれについて)、それを使用して配列を作成したい配列をループして、毎回新しいインスタンスを作成します。
以下の私のコードはかなり意味不明ですが、助けていただければ幸いです。
public class Test{
long startTime = System.currentTimeMillis();
long total = 0;
for (int i = 0; i < 10000000; i++) {
total += i;
randomValue1 = (int)(Math.random()*10);
randomValue2 = (int)(Math.random()*10);
Point[] instances = new Point[numberOfElements];
for (int i=0; i<instances.length; i++) {
instances[i] = new Point( ,randomValue1, randomValue2);
}
}
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
System.out.println(elapsedTime);
}