id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

norm.krumpe@muohio.edu > firstWord
prev  |  next  |  chance

Given non-empty array of lowercase non-empty strings, return the string that would be first alphabetically. Solve this by looking through the array. NOTE: The compareTo() method of the String class is useful for comparing words alphabetically. "cat".compareTo("dog") is negative because cat is alphabetically before dog. Similarly, "dog".compareTo("cat") is positive. And "cat".compareTo("cat") is 0.


firstWord(["cat", "banana", "dog", "tree"]) → "banana"
firstWord(["yak", "zebra", "xylophone"]) → "xylophone"
firstWord(["man", "many", "mandy", "manana"]) → "man"

...Save, Compile, Run (ctrl-enter)

String firstWord(String[] words) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200

Copyright Nick Parlante 2017 - privacy