1. We can convert char array to String by passing the array to String constructor.
public void convertCharArrayToStringOption1() { char[] charArray = new char[] { 'a', 'b', 'c', 'd' }; System.out.println("The new String Array is : "+new String(charArray));}
2. We can also pass the char array to 'valueOf()' static method of String class:
public void convertCharArrayToStringOption1() { char[] charArray = new char[] { 'a', 'b', 'c', 'd' }; System.out.println("The new String Array is : "+ String.valueOf(charArray));}
No comments:
Post a Comment