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

Java > String-1 > nTwice
prev  |  next  |  chance

Given a string and an int n, return a string made of the first and last n chars from the string. The string length will be at least n.

nTwice("Hello", 2) → "Helo"
nTwice("Chocolate", 3) → "Choate"
nTwice("Chocolate", 1) → "Ce"

...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  >  String-1

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

Copyright Nick Parlante 2006-10 - privacy