Como mudar String para Integer em ordem

Raito:

bilhete Array [x] [2] é String, e ticket [x] [1] é String também. O bilhete de matriz [x] [1] é { "1", "2", "3"}. Como preencher bilhete [x] [2]? Quero em inteiro. No meu código ainda é erro usando Integer.parseInt ().

String[][] ticket = new String[8][3];

for (int x = 0; x < limit; x++) {
    if(ticket[x][0].equals("festival")) {
        ticket[x][2] = Integer.parseInt(ticket[x][1]) * 250000;
    }
}
Elliott fresco:

Porque ticket[x][2]é um String(você está tentando atribuir um int).

ticket[x][2] = "" + (Integer.parseInt(ticket[x][1]) * 250000);

ou

ticket[x][2] = String.valueOf(Integer.parseInt(ticket[x][1]) * 250000);

Acho que você gosta

Origin http://43.154.161.224:23101/article/api/json?id=339030&siteId=1
Recomendado
Clasificación