DEV Community

loading...

Discussion on: Daily Challenge #1 - String Peeler

Collapse
adusoft profile image
Geofrey Aduda • Edited

java function using string builder

public String removefirstWordLastWord(String mystring )
{
///Delete last and first character

StringBuilder chr=new StringBuilder(mystring);
String strresult="";
if (mystring.length()>=2)
{
chr.deleteCharAt(0);
chr.deleteCharAt(chr.length()-1);
strresult=chr.toString();
}else{
strresult=("Invalid String");
}
}

Forem Open with the Forem app