Shared array
class TryInitialization { 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 i = 0; i < values.length; i++) System.out.print(" " + values[i]); } public static void main(String[] args) { TryInitialization example = new TryInitialization(); example.listValues(); TryInitialization nextexample = new TryInitialization(); nextexample.listValues(); example.listValues(); } }