public class MainClass {
static int[] values = new int[10];
{
System.out.println("Running initialization block.");
for (int i = 0; i < values.length; i++) {
values[i] = (int) (100.0 * Math.random());
}
}
void listValues() {
for (int value : values) {
System.out.println(value);
}
}
public static void main(String[] args) {
MainClass example = new MainClass();
System.out.println("\nFirst object:");
example.listValues();
example = new MainClass();
System.out.println("\nSecond object:");
example.listValues();
}
}
|