Given a string, return a version without the first and last char, so "Hello" yields "ell". The string length will be at least 2.

Check Below Code:

package com.test.strings;

public class StringFirstLast 
{
	public static void main(String args[])
	{
		StringFirstLast fl = new StringFirstLast();
		System.out.println(fl.firstLast("hello"));
		System.out.println(fl.firstLast("java"));
		System.out.println(fl.firstLast("coding"));
	}
		
	public String firstLast(String str) 
	{
		return str.substring(1, str.length()-1);	
	}
}

Output

ell
av
odin