Remove Duplicate Element in Array ====================================== Array ={10,20,10,30,50,40,30}; 1. Take one Arrays and sort this Array. Array={10,10,20,30,30,40,50}; 2. Removed this duplicate element in array. Coding : package InterviewQuestio; import java.util.Arrays; public class RemoveDuplicateElementInArray { public static void main(String[] args) { int arr[]= {10,20,10,30,50,40,30}; System.out.println(Arrays.toString(arr)); Arrays.parallelSort(arr);//Sorted array int j=0; int temp[]=new int[arr.length]; for(int i=0;i
=0) { System.out.print(arr[j--]+" "); } } }
😂 How can we create an Auto-generated field or ID for MongoDB using spring boot? First Create One Application Like Mongodb_sequence-id-generator Pom.XML org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-data-mongodb de.flapdoodle.embed de.flapdoodle.embed.mongo User.java package com.app; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Transient; import org.springframework.data.mongodb.core.mapping.Document; @Document(collection = "users_db") public class User { @Transient public static final String SEQUENCE_NAME = "users_sequence"; @Id private long id; private String firstName; private String lastName; private String email; public User() { } public User(String firstName, String lastName, String email) { this.firstName = firstName; this.lastName = la...
Comments
Post a Comment