Faire une concaténation mais u somation

Fermé
Nizar - Modifié par Aranud87 le 8/04/2014 à 20:50
walidovich_85 Messages postés 608 Date d'inscription mardi 12 janvier 2010 Statut Membre Dernière intervention 25 octobre 2015 - 8 avril 2014 à 21:42
Bonjour, svp j'aime pas faire une concaténation mais une somation

String query8 = "SELECT A0,A1,A2,A3 FROM simo WHERE Mode_canal = '"+jComboBox13.getSelectedItem()+"'";
try {
ResultSet resultset = statement.executeQuery(query8) ;
while (resultset.next()){
cxz=(resultset.getString(1));
axz=(resultset.getString(2));
bxz=(resultset.getString(3));
fxz=(resultset.getString(4));
jTextField21.setText(cxz+axz);
}
} catch (SQLException ex) {
Logger.getLogger(IntPrincipale.class.getName()).log(Level.SEVERE, null, ex);
}
A voir également:

1 réponse

walidovich_85 Messages postés 608 Date d'inscription mardi 12 janvier 2010 Statut Membre Dernière intervention 25 octobre 2015 73
8 avril 2014 à 21:42
Bonsoir,

Si tes variables cxz et axz doivent être des nombres, alors tu n'a qu'à faire un casting comme sui:

String s1 = new String("10");
String s2 = new String("20");
System.out.println("concaténation: " + s1 + s2);
System.out.println("Addition: " + (int) (Integer.parseInt(s1) + Integer.parseInt(s2)));


Le résultat:

concaténation: 1020
Addition: 30


Bonne chance
0