Liza
Liza

Reputation: 39

Split string by symbols and put symbols into variables. Java

I have a string variable. It's 4 digits number. I have to split this string into symbols and put every symbol into different variable. I haven't found how to do it with variables, only with arrays, but using arrays is not allowed. Any thoughts?

Upvotes: 0

Views: 49

Answers (1)

Alexanus
Alexanus

Reputation: 689

not sure if i understand the question correctly, but maybe this is a solution?

    String strNumber = "1234";
    char one = strNumber.charAt(0);
    char two = strNumber.charAt(1);
    char three = strNumber.charAt(2);
    char four = strNumber.charAt(3);

Upvotes: 4

Related Questions