Complete the method so that it returns a string with the first and last character removed from the input string
public class Class1 {
public static String clipEnds(String str) {
}
}
code:
import java.util.*;
import java.lang.*;
public class Class1
{
public static void main(String args[])
{
String name = "David Warner";
System.out.println(clipEnds(name));
}
public static String clipEnds(String str) {
String str1 = str.substring(1, str.length() -1);
return str1;
}
}
Screenshots:
Get Answers For Free
Most questions answered within 1 hours.