JAVA ARRAYLIST CONTAINS METHOD EXAMPLE DEMO

preview_player
Показать описание

HOW TO FIND DOES ARRAYLIST CONTAINS AN ELEMENT OR NOT DEMO
Рекомендации по теме
Комментарии
Автор

I have a question. I did the contains method in generic form and I was asked to use a Boolean method in a class. How do I call the method in main?my class:public boolean list, String name)
    {
       int i = 0;
        for  (i = 0; i < list.size(); i++)
        {
            list.get(i);
        } 
        if (list.size() > 1 && name.equals(list.get(0)))
              return true;
           else
                return false;    }how do I call this method in enter the name of a student: ");
                   
                    String sname = list = new ArrayList<>();
                   
                    if (stu.studentExists(list, sname) == true)
                    System.out.println(sname + " exists in the list.");
                   
                    else
                        System.out.println(sname + " does not exist.");Is this correct???

Sugandhrb