Created
June 6, 2017 19:54
-
-
Save MericBERBER/0792b8dfcdf95290e87c72ba56d46c6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class TestArrayAndLinkedList { | |
public static void main(String[] args) { | |
List<Integer> arrayList = new ArrayList<>(); | |
arrayList.add(1); | |
arrayList.add(2); | |
arrayList.add(3); | |
arrayList.add(1); | |
arrayList.add(4); | |
arrayList.add(0, 10); | |
arrayList.add(3, 30); | |
System.out.println("A list of integers in the array list:"); | |
System.out.println(arrayList); | |
LinkedList<Object> linkedList = new LinkedList<>(arrayList); | |
linkedList.add(1, "red"); | |
linkedList.removeLast(); | |
linkedList.addFirst("green"); | |
System.out.println("Baştan sona doğru yazdır :"); | |
ListIterator<Object> listIterator = linkedList.listIterator(); | |
while (listIterator.hasNext()) { | |
System.out.print(listIterator.next() + " "); | |
} | |
System.out.println(); | |
System.out.println("Sondan başa doğru yazdır :"); | |
listIterator = linkedList.listIterator(linkedList.size()); | |
while (listIterator.hasPrevious()) { | |
System.out.print(listIterator.previous() + " "); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment