Go Arrays - Program to find the duplicate elements of an Array

Go program to find the duplicate numbers in an Array

// Go program to find duplicate numbers in an Array
package main

import "fmt"

// Main function
func main() {

// Let’s define an array first
arr := [10]int{33, 2, 1, 22, 2, 6, 3, 1, 33, 9}

for i := 0; i < len(arr); i++ {
for j := i + 1; j < len(arr); j++ {
if arr[i] == arr[j] {
fmt.Println(arr[j])
}
}
}
}


Output:



Go program to find the duplicate words in an Array

// Go program to find duplicate words in an Array
package main

import "fmt"

// Main function
func main() {

// Let’s define an array first
arr := [10]string{
"Go", "Java", "Javascript",
"Python", "Php", "Kotlin",
"Vue", "C", "Go", "Python",
}

for i := 0; i < len(arr); i++ {
for j := i + 1; j < len(arr); j++ {
if arr[i] == arr[j] {
fmt.Println(arr[j])
}
}
}
}


Output:

Popular posts from this blog

Learn Java 8 streams with an example - print odd/even numbers from Array and List

Java Stream API - How to convert List of objects to another List of objects using Java streams?

Registration and Login with Spring Boot + Spring Security + Thymeleaf

Java, Spring Boot Mini Project - Library Management System - Download

ReactJS, Spring Boot JWT Authentication Example

Top 5 Java ORM tools - 2024

Java - Blowfish Encryption and decryption Example

Spring boot video streaming example-HTML5

Google Cloud Storage + Spring Boot - File Upload, Download, and Delete