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

Java > Array-2 > pre4
prev  |  next  |  chance

Given a non-empty array of ints, return a new array containing the elements from the original array that come before the first 4 in the original array. The original array will contain at least one 4. Note that it is valid in java to create an array of length 0.

pre4({1, 2, 4, 1}) → {1, 2}
pre4({3, 1, 4}) → {3, 1}
pre4({1, 4, 4}) → {1}

...Save, Compile, Run

See also Java Example Code. Java help docs: If Boolean Logic | Strings | While and For Loops | Arrays and Loops


prev  |  next  |  chance   |  CodingBat  >  Array-2

Forget It! -- delete my code for this problem 272.0

Copyright Nick Parlante 2006-10 - privacy