Concatenate chars to form String in java

后端 未结 6 925
[愿得一人]
[愿得一人] 2020-12-15 22:31

Is there a way to concatenate char to form a String in Java?

Example:

String str;
Char a, b, c;
a = \'i\';
b = \'c\';
c = \         


        
6条回答
  •  误落风尘
    2020-12-15 23:30

    Use str = ""+a+b+c;

    Here the first + is String concat, so the result will be a String. Note where the "" lies is important.

    Or (maybe) better, use a StringBuilder.

提交回复
热议问题