Problem z konwersją Stringa na Inta

0

Hej,
Mam problem z konwersją Stringa na Integera.

public class Position {

    int x;
    int y;
    String field;


    public void setField() {
        this.x = Integer.valueOf(field.charAt(0) - 64);
        this.y = Integer.parseInt(field[1]);   //tutaj wyrzuca błąd przy field[1]
        this.field = field;

    }
}

w js zrobiłem to w ten sposób:

function Pozycja(pole) { 
    this.x = 0;
    this.y = 0;
    this.ustaw(pole);

} 

Pozycja.prototype.ustaw = function(pole) {
    this.x = pole.charCodeAt(0)-64;
    this.y = parseInt(pole[1]);
    this.pole = pole;
};
0

Obiekt typu String nie może być traktowany jako tablica

1 użytkowników online, w tym zalogowanych: 0, gości: 1