A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Search an User in the ArrayList and show massage if Found then Found deleted in java

import java.util.ArrayList;
import java.util.Scanner;
class Simple
{
    public static void main(String args[])
    {
        ArrayList   mylist = new ArrayList();
        mylist.add("Heera");
        mylist.add("ravish");
        mylist.add("Aman");

       System.out.println("before deletion List is "+mylist);
       Scanner  sc = new Scanner(System.in);
       System.out.println("Enter name: ");
       String s=sc.next();
      
        if(mylist.contains(s)==true)
        {
            System.out.println("Found");
            mylist.remove(s);
            System.out.println(s+" Found deleted");
        }
        else
        {
            System.out.println("Not Found");
        }
       
        System.out.println("alfter deletion List is "+mylist);
    }
}


LEARN TUTORIALS

.

.