Java Lab Assignment
Write a method called convertToString. The method will take an array of chars as an argument and it will return a String. Each index of the array will be part of the each index of the String.
method must be well documented using JavaDoc, example:
/** * The find method checks if the target in the array
* @param String [] a - array of Strings
* @param String t - value to be searched for
* @return true if the String t is found, false otherwise
*/
//TestCode.java public class TestCode { static String convertToString(char arr[]){ String result = ""; for(int i = 0;i<arr.length;i++){ result += arr[i]; } return result; } public static void main(String[] args) { char arr[] = {'h','e','l','l','o'}; System.out.println(convertToString(arr)); } }
hello
Get Answers For Free
Most questions answered within 1 hours.