Concatenate Char to String in Java

Hi Programmers, Welcome to Ozanecare. The new article for java developer to learn how to concatenate Char with String. we can combine characters to strings with or without any method.Let’s see all coding.

1.Concatenating char to string by declaring String datatype variable and Character type variable. we can easily combine with plus(+) operator. see below image.

2.We can concatenate char to string by using StringBuffer class and append Method. s1 is the object of StringBuffer class. After StringBuffer class using dot(.) operator.The dot(.) operator is used to call append method and by using toString method it converts into string and merge with str variable. see below image.

3.We can concatenate char to string by using StringBuilder class and Append Method. s1 is the object of StringBuilder class , by using toString method it converts into string and merge with str variable. see below image.

Happy Coding…Thanks.

Post Author: adama