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

 

orion.a.smith@gmail.com apcsa-arrays > apcsaArraysConcatThreeNthCharacters
prev  |  next  |  chance

Requires String methods: skip if you do not know about substring yet


Given an array of three Strings and an int n, return a String made up of the character of each of the Strings with index n, in the same order as the array.  Precondition: each String in the input array will have length() >= 1.
HINT
You could use a loop, or not. Your choice, since you know the number of array elements beforehand. Suggestion: use substring(n, n+1) to get a character out of each String.

STRINGS VS ARRAYS

Remember that Strings have length as a method, meaning arr[0].length() instead of arr[0].length.  This gets confusing, and people often get it wrong the other way like arr.length() instead of arr.length - just come back up and look at this if you get confused.

apcsaArraysConcatThreeNthCharacters(["a", "b", "c"], 0) → "abc"
apcsaArraysConcatThreeNthCharacters(["gl", "oy", "be"], 1) → "lye"
apcsaArraysConcatThreeNthCharacters(["ark", "zei", "bin"], 2) → "kin"

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

public String apcsaArraysConcatThreeNthCharacters(String[] arr, int n) { }

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: 130

Copyright Nick Parlante 2017 - privacy