Here is another Java snippet that can help to enhance your program by using LinkedLists. The code below will retrieve all items from a linkedList and print them one by one to the console.

class Main {
   public static void main(String[] args) {
  java.util.LinkedList<String> employees = new    java.util.LinkedList<String>();
    employees.add("Scott");
    employees.add("Marie");
    employees.add("Dun");

    for (String string : employees)
          System.out.println(string);
  }

}

Happy Coding!

More Java Snippets

Last modified: May 24, 2019

Comments

Write a Reply or Comment

Your email address will not be published.