Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java get unique elements from array

String[] unique = Arrays.stream(array).distinct().toArray(String[]::new);
Comment

unique elements in array java

int [] arr = {1,1,1,2,2,2,3,3,3,4,4,5,5,6,7,8,};

for (int j= 0; j < arr.length; j++){
int count1 = 0; // to find out how many time value is appeared in the arry
for (int i = 0; i < arr.length; i++){
     if(arr[i] == arr[j] ) {    
    // if(arr[i] == 1 ) { once boyleydi ikinci for gelince soldaki oldu
      count1++; // arraydeki harfleri tek tek saymak icin
  }
 }
    if(count1 == 1 ){
    System.out.print(arr[j]+" ");// 6 7 8 uniqe
 }
Comment

PREVIOUS NEXT
Code Example
Java :: spring boot base url 
Java :: array sort java 
Java :: fill two dimensional array column by column java 
Java :: resize image icon to fit jlabel 
Java :: string to stream java 
Java :: java enums 
Java :: hide element selenium 
Java :: remove duplicates from sorted array 
Java :: android kill other app programmatically by package 
Java :: iterate thrpugh hasmap 
Java :: android-edittext allow only characters and numbers 
Java :: connect sqlite for java 
Java :: java timer 
Java :: java set foreach 
Java :: count occurrences of character in string java using hashmap 
Java :: list of numbers java 
Java :: java string to integer 
Java :: mockito mock void methods 
Java :: java formatted output 
Java :: is palindrome java 
Java :: java substring after last char 
Java :: java is list ordered 
Java :: java append a string to file 
Java :: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification 
Java :: install java using cmd 
Java :: how to use while loop in java 
Java :: apache csv get headers 
Java :: declare java class 
Java :: string methods in java 
Java :: writing values in 2d array java 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =