Visualizzazione dei risultati da 1 a 6 su 6

Discussione: java stringa

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2001
    Messaggi
    139

    java stringa

    Ciao a tutti !!
    Avrei una domanda per voi !!
    Io ho una stringa di numeri 1,2,3
    Io vorrei dividere questa stringa per la , e ogni valore metterlo dentro un array e scorrere l'array e scivere ogni valore a video!!!
    Come posso fare????

  2. #2
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    String s = "1,2,3";
    StringTokenizer st = new StringTokenizer(s, ",");
    while (st.hasMoreTokens())
    System.out.println(st.nextToken());

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2001
    Messaggi
    139
    Grazie mille!!!!!

  4. #4
    Utente di HTML.it
    Registrato dal
    Oct 2001
    Messaggi
    139
    String s = "1,2,3";
    StringTokenizer st = new StringTokenizer(s, ",");
    String wherecondition = "&& valorefisso!=";
    while (st.hasMoreTokens()) {
    // System.out.println(st.nextToken());
    String wherecondition += wherecondition+ st.nextToken();
    System.out.println(wherecondition);

    Ho fatto cosi pero non riesco a costruire questa stringa

    && valorefisso!=1 "&& valorefisso!=2 "&& valorefisso!=3
    come posso fare??

  5. #5
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    StringTokenizer st = new StringTokenizer(s, ",");
    String wherecondition = "&& valorefisso!=";
    String condition = "";
    while (st.hasMoreTokens())
    condition += wherecondition + st.nextToken();

    gli apici non mi pare abbiano senso, ne metti 2 su tre stringhe, beh il codice giusto č questo

  6. #6
    Utente di HTML.it
    Registrato dal
    Oct 2001
    Messaggi
    139
    Grazie mille!!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.