import java.util.ArrayList;


public class DuplicateRemover {
	
	public static void main(String[] args) {
		DuplicateRemover dup = new DuplicateRemover();
		String before = "This is a sample sentence that contains some duplicates that should be removed though doing so will make this sentence no longer make sense";
		System.out.println("Before: " + before);
		String after = dup.removeDuplicates(before);
		System.out.println("After: " + after);
	}
	
	public String removeDuplicates(String words) {
		ArrayList<String> list = new ArrayList<String>();
		
		String[] separated = words.split(" ");
		String result = "";
		
		for (int i = 0; i < separated.length; i++) {
			if (!list.contains(separated[i])) {
				list.add(separated[i]);
				result += separated[i] + " ";
			}
		}
		
		return result;
	}
}

