Question: Programming Practice Method:public static char[] firstChars(String[] arr) Creates an array containing the first character of each entry in an array of Strings. If arr is

Programming Practice

Method:public static char[] firstChars(String[] arr)

Creates an array containing the first character of each entry in an array of Strings. If arr is null, returns null. Otherwise, it returns an array containing the first letter of each entry in arr. If an entry of arr is null or empty, the corresponding entry in the output should be ?. For example firstChars({"hello","world",null,"lol","","yolo"}) should return ['h','w','?','l','?','y'].

Parameters: arr The input array.

Returns: An array containing the first character of each entry in arr if arr is not null, or null if arr is null.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!