How to store every word of one input field in a new string

thankyou

I can get the input into one string. Like that:

input = (EditText)findViewById(R.id.input1);
text = (TextView)findViewById(R.id.text1);

String value = input.getText().toString();
text.setText(value);

But how can I get the text of the input and store each word in a single variable? I searched very long but nothing worked.

Prateek

Use toCharArray() method of String class

char[] values = value.toCharArray();

EXAMPLE

String value = "Hello";
char[] values = value.toCharArray();

for(char c: values){
    System.out.println(" "+ c);
}

OUTPUT

H
e
l
l
o

FOR SPLITTING INTO STRING

Use split(String regex) method

EXAMPLE

String value = "Hello My Friends";
    String[] values = value.split(" ");

    for(String c: values){
        System.out.println(" "+ c);
    }

OUTPUT

Hello
My
Friends

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to create a new json string by changing one particular field in it?

From Dev

Laravel: How to store href id in the new variable and display or use in the input field?

From Dev

How to capitalise the first letter of every word in a string

From Dev

How to capitalise the first letter of every word in a string

From Dev

How to replace every second occurrence of a word in a string

From Dev

Get first word on every new line in a long string?

From Dev

How to store each word in a string into specific variables?

From Dev

How to create a text field one by one on every click of a button?

From Dev

Frequency of every Word in a String

From Dev

How to replace every comma with a new word from a file

From Dev

how to disable one of the input field if it does not qualify

From Dev

i want to update an array with an input field, but instead it creates a new one

From Dev

How to break one field into 3 new columns

From Dev

input strings in c and how to store the string into variable

From Dev

One byte char array appears to store 8 input string characters

From Dev

How to proper calculated one input field and many output field summation?

From Dev

Limit an input to one word

From Dev

How can you store more than one word in a php $_SESSION?

From Dev

How store data in an associative array from an input field?

From Dev

How to store text field input as a variable for textToImage function?

From Dev

How to store onchange selected dropdown value into hidden input field?

From Dev

How to display every message in a thread with at least one new message?

From Dev

How to make a new line for every space, except one?

From Dev

How to store more than one image reference in a database field

From Dev

How to add string(word) to String[]array?Java, input

From Dev

Reverse every word in a string and capitalize the start of the word

From Dev

How to read a CSV file line by line and store it to new CSV file on new row every time?

From Dev

Skipping the special characters from users input of a text string and adding Hyphen after every word in Javascript

From Dev

Changing every other letter in a string (JavaScript)? Each new word starts 0 based

Related Related

  1. 1

    How to create a new json string by changing one particular field in it?

  2. 2

    Laravel: How to store href id in the new variable and display or use in the input field?

  3. 3

    How to capitalise the first letter of every word in a string

  4. 4

    How to capitalise the first letter of every word in a string

  5. 5

    How to replace every second occurrence of a word in a string

  6. 6

    Get first word on every new line in a long string?

  7. 7

    How to store each word in a string into specific variables?

  8. 8

    How to create a text field one by one on every click of a button?

  9. 9

    Frequency of every Word in a String

  10. 10

    How to replace every comma with a new word from a file

  11. 11

    how to disable one of the input field if it does not qualify

  12. 12

    i want to update an array with an input field, but instead it creates a new one

  13. 13

    How to break one field into 3 new columns

  14. 14

    input strings in c and how to store the string into variable

  15. 15

    One byte char array appears to store 8 input string characters

  16. 16

    How to proper calculated one input field and many output field summation?

  17. 17

    Limit an input to one word

  18. 18

    How can you store more than one word in a php $_SESSION?

  19. 19

    How store data in an associative array from an input field?

  20. 20

    How to store text field input as a variable for textToImage function?

  21. 21

    How to store onchange selected dropdown value into hidden input field?

  22. 22

    How to display every message in a thread with at least one new message?

  23. 23

    How to make a new line for every space, except one?

  24. 24

    How to store more than one image reference in a database field

  25. 25

    How to add string(word) to String[]array?Java, input

  26. 26

    Reverse every word in a string and capitalize the start of the word

  27. 27

    How to read a CSV file line by line and store it to new CSV file on new row every time?

  28. 28

    Skipping the special characters from users input of a text string and adding Hyphen after every word in Javascript

  29. 29

    Changing every other letter in a string (JavaScript)? Each new word starts 0 based

HotTag

Archive