Monday, January 21, 2019

Write a Java Program to remove duplicate values from an array?

package seleniumrepo;

public class DisticntElements {
    public static void printDistinctElements(int[] arr){
        for(int i=0;i<arr.length;i++){
            boolean isDistinct = false;
            for(int j=0;j<i;j++){
                if(arr[i] == arr[j]){
                    isDistinct = true;
                    break;
                }
            }
            if(!isDistinct){
                System.out.print(arr[i]+" ");
            }
        }
    }
   
    public static void main(String a[]){
        int[] nums = {5,2,7,2,4,7,8,2,3};
        DisticntElements.printDistinctElements(nums);
    }
}

Related Posts:

  • Manual Testing Interview QuestionsDifference between Smoke Testing and Sanity Testing?Smoke Testing: Smoke Testing build Verification testing to check the basic functionalities of an application are working after a new build. If build is stable enou… Read More
  • Java Program to Insert array2 into array1 at given position Java Program: Take 2 arrays, write a method to - Insert array2 in to array1 at given position//Output: {12, 13,14,5,6,15}package qasign;import java.util.ArrayList;import java.util.Arrays;public class SampleTest { public… Read More
  • Reverse Each Word in a String Input "hello world java"  1) Reverse each word in a string Input: hello world java     //Output: olleh dlrow avaj String str="hello world java"; String[] tokens=str.split(" "); for(int i=0;i<tokens.length;i++) { for(int j=… Read More
  • Manual Testing QuestionsWhat is Smoke Testing?Smoke Testing: This is build acceptance Testing performed after build is released to the Testing. This Testing is done to check the major functionalities are working fine or not.What is Sanity Testing?Sa… Read More
  • Write a Java Program to Add Map Elements and Print  package qasignpackage;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Map.Entry;public class SampleTest {    public … Read More

0 comments:

Post a Comment

Selenium Training in Realtime

Blog helps to a student or IT employee to develop or improve skills in Software Testing.

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *

Popular Posts