How to separate a text string by means of a space? [duplicate]

0

In my code: String nex = keyboard.next (). Split ('/ n'); (Keyboard is Scanner type) How can you identify the space in the .split () and the end of the string.

    
asked by Juan D Villamil 30.08.2017 в 03:55
source

1 answer

0

It is achieved in the following way:

    String nex = teclado.nextLine();  //se debe leer con nextLine no con next
    String separado[]=nex.split(" ");

Separated is an arrangement which contains what you have read separated by spaces.

    
answered by 30.08.2017 в 04:09