Bael 3207 convert char array to string (#7720)

* BAEL-320 Convert Char Array to String

* BAEL-3207 re-formatting

* BAEL-3207 some changes
This commit is contained in:
Shubhra Srivastava 2019-09-04 10:11:21 +05:30 committed by maibin
parent 7472127909
commit c4a1b44b39
1 changed files with 5 additions and 6 deletions

View File

@ -41,11 +41,11 @@ public class CharArrayToStringConversionUnitTest {
@Test @Test
public void whenStringBuilder_thenOK() { public void whenStringBuilder_thenOK() {
final char[] charArray = { 'b', 'a', 'e', 'l', 'd', 'u', 'n', 'g' }; final char[][] arrayOfCharArray = { { 'b', 'a' }, { 'e', 'l', 'd', 'u' }, { 'n', 'g' } };
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (char value : charArray) { for (char[] subArray : arrayOfCharArray) {
sb.append(value); sb.append(subArray);
} }
assertThat(sb.toString(), is("baeldung")); assertThat(sb.toString(), is("baeldung"));
@ -65,9 +65,8 @@ public class CharArrayToStringConversionUnitTest {
public void whenGoogleCommonBaseJoiners_thenOK() { public void whenGoogleCommonBaseJoiners_thenOK() {
final Character[] charArray = { 'b', 'a', 'e', 'l', 'd', 'u', 'n', 'g' }; final Character[] charArray = { 'b', 'a', 'e', 'l', 'd', 'u', 'n', 'g' };
String string = Joiner.on("").join(charArray); String string = Joiner.on("|").join(charArray);
assertThat(string, is("baeldung")); assertThat(string, is("b|a|e|l|d|u|n|g"));
} }
} }