โ Back to Methods
Question 175
Return the First Item from a Generic Array
Return the First Item from a Generic Array
Complete the generic methodgetFirstthat takes an array of any type and returns its first element. You may assume the array always has at least one item. IMPORTANT: Do NOT write a main method. A hidden test will callGenericTools.getFirstwith a String array and an Integer array and print the first element from each. Expected Output: apple 7
Expected Output:
apple 7
Topics:
GenericsMethods
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.