What is the best way to put a char array in the string?

Asked 2 years ago, Updated 2 years ago, 177 views

char[] a = {'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'}; There's a string like this

String b = new String(a); Is there a better way than this?

string java array char

2022-09-22 22:23

1 Answers

No, that's the most concise and good way. But just to tell you one thing, splitting each string into a char array and putting it back into the string doesn't really happen in normal code.


2022-09-22 22:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.