K
K
keddad2020-04-17 13:05:19
Java
keddad, 2020-04-17 13:05:19

How to make a string from ArrayDeque?

I have a struct ArrayDeque<Character>and I want to convert it to a string. If it were an array of chars, I could do this:

char[] chars = { 'A', 'B', 'C', 'D', 'E', 'F' };
String stringFromChars = String.valueOf(chars); // "ABCDEF"


But if I do the same with ArrayDeque, it's bullshit:
String(String.valueOf(pass_raw))-> [A, B, C, D, E, F]

Okay, but I can translate this into an array of chars, and do the same thing with it? No, I can't: it
pass_raw.toArray()returns not char[], but Object[]. How in this case to me to receive a line?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Pokrovsky, 2020-04-17
@keddad

StringBuilder str = "";
for (char c : arrayDeque) {
    str.append(c);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question