DoubleMapGenotype extends DoubleGenotype implements MapGenotype<K, Double> { @Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("["); for (int i = 0; i < size(); i++) { K key = keys.get(i); double value = this.get(i); stringBuilder.append(key + "=" + value + ";"); } stringBuilder.append("]"); return stringBuilder.toString(); } DoubleMapGenotype(List<K> keys, Bounds<Double> bounds); void init(Random random); @Override void init(Random random, int n); @Override boolean containsKey(K key); @Override Double getValue(K key); @Override void setValue(K key, Double value); @Override @SuppressWarnings({ "unchecked", "rawtypes" }) G newInstance(); @Override String toString(); @Override int getIndexOf(K key); @Override Collection<K> getKeys();  }
@Test public void testToString() { List<MockObject> keys = new ArrayList<>(); MockObject m1 = new MockObject(1); MockObject m2 = new MockObject(2); keys.add(m1); keys.add(m2); DoubleMapGenotype<MockObject> doubleMapGeno = new DoubleMapGenotype<>(keys, new MockBounds()); doubleMapGeno.init(new Random()); assertEquals("[m1=1.0;m2=1.0;]", doubleMapGeno.toString()); }