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

 

siochi@cnu.edu cpsc140practice > indexOf
prev  |  next  |  chance

indexOf() -- given a String and an array of Strings, return the index of that String in the array. If the String is not in the array, or the array is empty, -1 should be returned. If the String occurs more than once in the array, return the index of the first occurrence of that String.


indexOf("a", ["b", "a", "a"]) → 1
indexOf("b", ["b", "a", "a"]) → 0
indexOf("x", ["b", "a", "t"]) → -1

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

public int indexOf(String ch, String[] chs) { }

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 Post-solution available

Copyright Nick Parlante 2017 - privacy