How can i verify if i'm adding atributes to a list that are equal?

import entidades.*;

public class Main {

    public static void main(String[] args) {
        Profissional prof = new Profissional(null, null);
        List<Profissional> profissional = new ArrayList<Profissional>();
        Scanner sc = new Scanner(System.in);
        boolean loop = true;
        while(loop == true) {
            String comando = sc.next().toUpperCase();

            if (comando.contentEquals("RP")) {
                String nomePro = sc.nextLine();
                String categoriaPro = sc.nextLine();
                prof.NomeVerificacao(profissional, nomePro, categoriaPro);
            }
            if(comando.contentEquals("SAIR")) {
                break;
            }
        }

        for(Profissional pro : profissional) {
            System.out.println(pro);

This is my Main, it's running fine but i don´t think it is adding the atributes to the list and not verifying either.

i want to add the atributes to a list so i can create different objets but they can not have at least the name equal.

public class Profissional {
    private String nome;
    private String categoria;

    public Profissional(String nome, String categoria) {
        this.nome = nome;
        this.categoria = categoria;
    }


        public void NomeVerificacao(List<Profissional> profissional ,String nome, String categoria) {
        if(profissional.isEmpty() == true) {
            profissional.add(new Profissional(nome, categoria));
        }else {
            for(Profissional pro : profissional) {
                if(pro.nome.contentEquals(nome)) {
                    System.out.println("Já Exite esse nome");

                }else {
                    profissional.add(new Profissional(nome, categoria));    
                }
            }
        }
    }

    @Override
    public String toString() {
        return "nome=" + nome + ", categoria=" + categoria;
    }


}

this is the Profissional Class.

I'm almost there i think but the output keeps saying that the name exists even though it is the first name i'm inserting.

I ran your code on my machine and made 3 changes into it, and it's working for me now,

1)

String nomePro = sc.next(); String categoriaPro = sc.next();

2) In professional class just changed this function a bit:

public void NomeVerificacao(List<Profissional> profissional, String nome, String categoria) {
    if (profissional.isEmpty() == true) {
        profissional.add(new Profissional(nome, categoria));
    } else {
        int i = 0;
        for (; i < profissional.size(); i++) {
            if (profissional.get(i).nome.equals(nome)) {
                System.out.println("Já Exite esse nome");
                break;
            }
        }
        if (i == profissional.size()) {
            profissional.add(new Profissional(nome, categoria));
        }
    }
}

3) At the end of the class Main, wrote sc.close(); to close the scanner.

i/p and o/p : 
1) RP
   red
   color
2) RP
   orange
   color
3) RP
   orange
   paint
   Já Exite esse nome

4) SAIR
   nome=red, categoria=color
   nome=orange, categoria=color

As you can see in above i/p and o/p, nome=red and nome=orange with categoria=color are added in the list but when we tried to add the same nome=orange again but with different category as paint it didn't add it and printed the message "Já Exite esse nome". and after entering SAIR, the toString(); printed the list content at the end. So the message will be printed only if we try to add the object with the same name again int list (not the first or any other times).

Further optimizations are possible but for now, it will work!

Check if a vehicle is taxed, Check and report if a vehicle has up-to-date vehicle tax or is 'off road' (SORN) Find Check Verify Online. Get Useful Information In Seconds. Visit Today & Quickly Get More Results On Fastquicksearch.com!

I can propose the following solution:

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    // Set is a data structure that makes sure you don't have a duplicated elements
    // in this case we use TreeSet structure that accepts comparator which tells that
    // we need to compare elements only by professional's name
    Set<Profissional> profissionals = new TreeSet<>(Comparator.comparing(Profissional::getNome));

    while (true) {
        String comando = sc.next().toUpperCase();

        if (comando.contentEquals("RP")) {
            String nomePro = sc.next();
            String categoriaPro = sc.next();
            
            // add function returns true in case the element we're going to add
            // was not presented in Set structure yet. False otherwise.
            boolean isNew = profissionals.add(new Profissional(nomePro, categoriaPro));
            if (!isNew) {
                System.out.println("Professional with name " + nomePro + " already exists");
            } else {
                System.out.println("Professional with name " + nomePro + " was added");
            }
        } else if (comando.contentEquals("SAIR")) {
            break;
        }
    }
    
    // just prints all professionals at the end of the program
    profissionals.forEach(System.out::println);
}

public static class Profissional {

    private String nome;
    private String categoria;

    public Profissional(String nome, String categoria) {
        this.nome = nome;
        this.categoria = categoria;
    }

    // getters and setters

    @Override
    public String toString() {
        return "nome=" + nome + ", categoria=" + categoria;
    }
}

The output will be the following:

RP

test test

Professional with name test was added

RP

test1 test1

Professional with name test1 was added

RP

test test3

Professional with name test already exists

SAIR

nome=test, categoria=test

nome=test1, categoria=test1

Email Address Verifier, Email Hippo's online,free,email verification tool. Check if email addresses are valid. Verify email addresses and then download results as PDF,CSV. Try for� Each year, companies worldwide lose billions due to check fraud. Even though this payment method is no longer as popular as it used to be, the risks are still there. Thanks to the modern technology, you can now verify funds on a check for free. All you need is the bank routing number.

package javaapplication8;

import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class JavaApplication8 {

    public static class Profissional {
        private String nome;
        private String categoria;

        public Profissional(String nome, String categoria) {
            this.nome = nome;
            this.categoria = categoria;
        }
    }

    public static void main(String[] args) {
        try {            
            List<Profissional> profissionalList= new ArrayList<>();

            Scanner sc = new Scanner(System.in);
            while(true) {

                System.out.print("\r\nEnter comando:");
                String comando = sc.next().toUpperCase();

                if (comando.contentEquals("RP")) {                
                    System.out.print("nome: ");              
                    String nome = sc.next();
                    sc.nextLine(); // wait enter

                    System.out.print("categoria: ");              
                    String categoria = sc.next();
                    sc.nextLine(); // wait enter

                    // access constructor of Profissional
                    Constructor profCtor =  Profissional.class.getConstructor(String.class, String.class);
                    profCtor.setAccessible(true);                        
                    // create instance of Profissional
                    Profissional newItem = (Profissional) profCtor.newInstance(nome, categoria);

                    // avoid duplicate nome in profissionalList
                    boolean isExist = false;
                    for(Profissional pro : profissionalList) {
                       if(pro != null){
                           if(pro.nome.toLowerCase().equals(newItem.nome.toLowerCase())){
                               isExist = true;
                               break;
                           }
                       }
                    }
                    if(!isExist){
                        profissionalList.add(newItem );
                    }
                }
                if(comando.contentEquals("SAIR")) {
                    break;
                }
            }

            for(Profissional pro : profissionalList) {
                if(pro != null) {
                    System.out.println("nome: " + pro.nome + " categoria: " + pro.categoria);
                }
            }
        }
        catch(Exception ex){
            System.out.println(ex.getMessage());             
        }
    }

}

Verifying Social Security Numbers, The Social Security Number Verification Service - This free online service allows registered users to verify that the names and Social Security numbers of hired� If you can’t verify funds (or if you want to be especially cautious), take the check to a branch of the bank that the funds are drawn on. You might be able to cash the check there instantly without depositing it—which eliminates the chance of the check bouncing.

Verify it's you - Android - Google Account Help, Verify it's you. To help protect your account, you may need to prove it's you if you recently signed out on your device or for sensitive actions, like when you:. It takes less than 30 seconds to check your registration status with our free 50-state tool. And if you're not registered, we'll help you take care of that too. Fast, free, secure, non-partisan.

Check for an account that exists, If we can't find an account that matches: We'll let you know. Double-check for typos, or try a different email address or phone number. If we're still unable to find a� The check writer can withdraw funds from the account before you deposit the check. You might deposit the check immediately after verifying it, but it can take a day or two for the check to hit the check writer’s account. Even if you deposit the check with your bank’s mobile deposit app, the process might still take a day or two.    

Confirm You're Registered to Vote, Check your voter registration status to confirm that you're able to vote in the next election. If you're an active voter, you should not have to� Self Check lets you confirm that your employment eligibility information is in order by checking it against the same databases E-Verify uses when employers enter a case. If Self Check finds a data-mismatch, you can receive instructions to correct your records with the appropriate federal agency.

Comments
  • Your problem being?
  • Let me clarify some details. You have a console input and if keyword "RP" in typed it indicates that further input will have : "name category" format until the keyword "SAIR" is entered, right? So you'd like to read the entire file into a list without name duplication. Am I right?
  • It's more like a command that means "Register Professional".
  • and i'm trying to see if i have professionals in this "Hospital" that have the name.
  • it's basically what you said but i don't understand the "Files" part
  • you only changed the Professional class??
  • How do i give more reputation?? because i was around this long time
  • Filipe Mota thanks for your acknowledgement. I don't know abt reputation m new here :P
  • Ya the major change was in your professional class. I am happy that it worked for u!
  • Just other thing! i edited the "NomeVerificacao" function and your code works perfectly but i want to understand why mine doen't work :( can you see the error?
  • Don't know if i can do that way but i'll try to take the idea!
  • I will put some comments then :) Give me a minute
  • The thing is i can't use that "TreeSet" it has to be an array.
  • Don't know if it is basically the same but i don't think i can use that