Java tutorial
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2005 Actuate Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Actuate Corporation - initial API and implementation *******************************************************************************/ import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { private static String[] distinct(String[] sValues) { Arrays.sort(sValues); List tempList = new ArrayList(); tempList.add(sValues[0]); for (int i = 1; i < sValues.length; i++) { if (!sValues[i].equals(sValues[i - 1])) { tempList.add(sValues[i]); } } String[] result = new String[tempList.size()]; for (int i = 0; i < result.length; i++) { result[i] = (String) tempList.get(i); } return result; } }