0
Starting in java programming and would like to know how to make code cleaner, this is an example of a recent code I created
public void chamarButton(JTextField login, JTextField senha){
        String pass = "";
        Connection connection = Connectionfactory.getConnection();
        try{
            String sqlLogin = "select senha from administrador where login = " + "'"+login.getText()+"'";
            Statement statement = connection.createStatement();
            ResultSet resultSetlogin = statement.executeQuery(sqlLogin);
            while(resultSetlogin.next()){
               pass = resultSetlogin.getString(1);
                System.out.println(resultSetlogin.getString(1));
            }
             if (pass.equals(senha.getText())){
                 JOptionPane.showMessageDialog(new JFrame(),"SUCESSO");
                 this.ativo = true;
             }else if(pass == "")
                 JOptionPane.showMessageDialog(new JFrame(),"Login errado");
             else
                 JOptionPane.showMessageDialog(new JFrame(), "senha errada");
                  resultSetlogin.close();
        }catch (SQLException e){
            JOptionPane.showMessageDialog(new JFrame(),"ERRO AO LOGAR");
            e.printStackTrace();```
Como deixar ele mais limpo por exemplo
To compare strings is used
equalsinstead of==, then it would beif ("".equals(pass))– hkotsubo