How to check if a client already exist in array in java

Newbie here.

I just want to ask, how to disallow someone to enter the same element in an array?

this is my code currently and it's not working properly:

import java.util.*;

public class Main {

public static void main(String[] args) {

Scanner input=new Scanner(;

String[] username=new String[5];

for (int c=0;c<5;c++)


System.out.print("Enter client name: ");


if (username.equals(username[c]))


System.out.println("The client already exist.");





p.s. I hope you guys can help me....

Read More »

By: StackOverFlow - Friday, 9 November

Related Posts