http://openbook.galileodesign.de/jav...0003911F01B105
du brauchst eine HashMap<int, int>.
PHP-Code:
HashMap<int,int> qZahlen = new HashMap<int,int> ();
qZahlen.put (1, 1);
qZahlen.put (2, 4);
qZahlen.put (3, 9);
......
wobei das befüllen von qZahlen eben die funktion quadratzahlenEinlesen:
PHP-Code:
public void quadratzahlenEinlesen(int pZahl)
{
qZahlen.put (pZahl, pZahl ** 2);
}
// falls es den ** operator nicht gibt eben:
.put (pZahl, (int) Math.pow ((double) pZahl, 2));