Problem:
Given a string, return a version without the first and last char, so "Hello" yields "ell". The string length will be at least 2.
withoutEnd("Hello") → "ell"
withoutEnd("java") → "av"
withoutEnd("coding") → "odin"
Solution:
public String withoutEnd(String str) { int len = str.length(); return str.substring(1,len - 1); }
It didn't work
ReplyDeletetry hacking the mainframe with this, 284097504398989849589430853290-4760234768^&^#$@(*&^&$%^&*()(*&^%$#$%
Deletepublic String withoutEnd(String word) {
ReplyDeletereturn word.substring(1, word.length() - 1);
}
public String withoutEnd(String str) {
ReplyDeleteString put="";
for (int i = 1; i <str.length()-1 ; i++) {
put+=str.substring(i,i+1);
}
return put;
}