About 209,000 results
Open links in new tab
  1. Array Copy in Java - GeeksforGeeks

    Nov 25, 2024 · In Java, copying an array can be done in several ways, depending on our needs such as shallow copy or deep copy. In this article, we will learn different methods to copy arrays in Java. Example: Assigning one array to another is an incorrect approach to copying arrays.

  2. java - Make copy of an array - Stack Overflow

    You can use either Arrays.copyOf() which will copy from the first to Nth element to the new shorter array. public static <T> T[] copyOf(T[] original, int newLength) Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length.

  3. Find duplicate elements in an array - GeeksforGeeks

    Dec 19, 2024 · Given an array of n integers. The task is to find all elements that have more than one occurrences. The output should only be one occurrence of a number irrespective of the number of occurrences in the input array. Examples: Note: Duplicate elements can be printed in …

  4. Java Array, Finding Duplicates - Stack Overflow

    Oct 17, 2010 · possible duplicate of Java: Detect duplicates in ArrayList? -- It's not entirely the same but... note the use of a Set/intermediate "store" vs. a nested loop. In your case, zipcodeList[k] == zipcodeList[j] for every k == j.

  5. Arrays copyOf() in Java with Examples - GeeksforGeeks

    Nov 11, 2024 · Arrays.copyOf () is a method of java.util.Arrays class. It is used to copy the specified array, truncating or padding with false (for boolean arrays) if necessary so that the copy has the specified length.

  6. How to Copy an Array in Java - Baeldung

    May 11, 2024 · It provides an easy way to copy a sub-sequence of an array to another. If any of the array arguments is null, it throws a NullPointerException. If any of the integer arguments is negative or out of range, it throws an IndexOutOfBoundException. Let’s look at an example of copying a full array to another using the java.util.System class:

  7. Program to Print the Duplicate Elements of an Array - Java

    Jan 20, 2025 · Finding duplicate elements in an array is a commonplace programming hassle that assesses the know-how of statistics systems and algorithms. Understanding the different methods to find duplicates efficiently is essential to creating …

  8. Duplicate elements of array in Java - Stack Overflow

    How to duplicate elements of an array in Java and add them to a new array in the same order of the original array? // The returned array should then contain {4, 4, 16, 16, 8, 8}. int duplicate = 0 ; int [] newArray = new int [elements.length*2]; for(int i = 0; i …

  9. How To Find Duplicates In Array In Java? - 5 Methods - Java

    Jan 21, 2019 · In this post, we will learn to find duplicate elements in array in java using Brute Force method, using Sorting method, using HashSet, using HashMap and using Java 8 Streams. Let’s see them one by one.

  10. Find Duplicate Elements and Their Frequency in an Array in Java

    Jan 5, 2023 · Learn how to find duplicate elements and their frequency in an array using Java. This guide provides step-by-step instructions and code examples.

  11. Some results have been removed
Refresh