import java.util.Arrays;
import java.util.LinkedHashSet;
public class ArrayExample
{
public static void main(String[] args) throws CloneNotSupportedException
{
//Array with duplicate elements
Integer[] numbers = new Integer[] {1,2,3,4,5,1,3,5};
//This array has duplicate elements
System.out.println( Arrays.toString(numbers) );
//Create set from array elements
LinkedHashSet<Integer> linkedHashSet = new LinkedHashSet<>( Arrays.asList(numbers) );
//Get back the array without duplicates
Integer[] numbersWithoutDuplicates = linkedHashSet.toArray(new Integer[] {});
//Verify the array content
System.out.println( Arrays.toString(numbersWithoutDuplicates) );
}
}
import java.util.LinkedHashSet;
public class ArrayExample
{
public static void main(String[] args) throws CloneNotSupportedException
{
//Array with duplicate elements
Integer[] numbers = new Integer[] {1,2,3,4,5,1,3,5};
//This array has duplicate elements
System.out.println( Arrays.toString(numbers) );
//Create set from array elements
LinkedHashSet<Integer> linkedHashSet = new LinkedHashSet<>( Arrays.asList(numbers) );
//Get back the array without duplicates
Integer[] numbersWithoutDuplicates = linkedHashSet.toArray(new Integer[] {});
//Verify the array content
System.out.println( Arrays.toString(numbersWithoutDuplicates) );
}
}
โค2๐1
240-core-java-interview-questions-and-answers.pdf
502.6 KB
๐4โค1๐1
๐1
Hello aap sabhi ko mera pranam
Kis ka material jyada chaiye bataye
Apne Chanel ko share jarur kare
Kis ka material jyada chaiye bataye
Apne Chanel ko share jarur kare
Anonymous Poll
89%
Java
2%
C language
1%
C++
2%
Angular js
5%
Java script
1%
Any other
๐10โค2
Murali Sir SQL Complete Notes.pdf
1.5 MB
๐ฅ2โค1๐1