## Problem:

Given a string, return a string length 1 from its front, unless front is false, in which case return a string length 1 from its back. The string will be non-empty.

theEnd("Hello", true) → "H"
theEnd("Hello", false) → "o"
theEnd("oh", true) → "o"

## Solution:

public String theEnd(String str, boolean front) {
if (front)
return str.substring(0,1);
else
return str.substring(str.length()-1);
}

1. public String theEnd(String str, boolean front) {
if(front){
return String.valueOf(str.charAt(0));
}
return String.valueOf(str.charAt(str.length() - 1));
}

2. public String theEnd(String str, boolean front) {
if(front){
return String.valueOf(str.charAt(0));
}
return String.valueOf(str.charAt(str.length() - 1));
}

3. public String theEnd(String str, boolean front) {
if(front){
return String.valueOf(str.charAt(0));
}
return String.valueOf(str.charAt(str.length() - 1));
}

4. public String theEnd(String str, boolean front) {
int leng = str.length();
return (front == true) ? str.substring(0,1) : str.substring(leng-1,leng);
}