import java.util.LinkedList;
public class RemoveOccurance {
public static void main(String[] args) {
// TODO Auto-generated method stub
LinkedList<String> ll1 = new LinkedList<>();
ll1.add("One");
ll1.add("Two");
ll1.add("Three");
ll1.add("Four");
ll1.add("Five");
ll1.add("Two");
ll1.add("Three");
ll1.add("Four");
ll1.add("Three");
ll1.add("Four");
ll1.add("Five");
ll1.add("Two");
System.out.print("\n Full-List : " + ll1);
System.out.print("\n Remove first 'Three' Occurance : " + ll1.removeFirstOccurrence("Three"));
System.out.print("\n Full-List : " + ll1);
System.out.print("\n Remove last 'Four' Occurance : " + ll1.removeLastOccurrence("Four"));
System.out.print("\n Full-List : " + ll1);
}
}
No comments:
Post a Comment