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 int[] distinct(int[] iValues) { Arrays.sort(iValues); List tempList = new ArrayList(); tempList.add(new Integer(iValues[0])); for (int i = 1; i < iValues.length; i++) { if (iValues[i] != iValues[i - 1]) { tempList.add(new Integer(iValues[i])); } } int[] result = new int[tempList.size()]; for (int i = 0; i < result.length; i++) { result[i] = ((Integer) tempList.get(i)).intValue(); } return result; } }