Java nima Java dasturlash tili


Download 1.25 Mb.
bet40/49
Sana20.01.2023
Hajmi1.25 Mb.
#1103409
1   ...   36   37   38   39   40   41   42   43   ...   49
Bog'liq
2 5420273372074344755



Javada LinkedList classi

  • Javada LinkedList doubly linked list dan foydalanib elementlarni yig’adi. U AbstractList clasidan meros(extends) oladi va List va Deque interface lardan implement oladi ArrayListdan farqlaridan ham biri Deque dan implement olishidur.

  • LinkedList da bir xil elementlar saqalsh mumkun

  • LinkedList da malumotlar krirtilish ketma ketligida saqlanadi

  • LinkedList class sinxron emas

  • LinkedList classda boshqarish jarayonlari tez sodir bo’ladi chunkiy LinkedList da elementlarni ko’chirib o’tkazilmaydi

  • LinkedList list, steck yokiy queue lardan foydalanishi mumkun

LinkedList da ham ma’lumotlar bilan ishlash ArrayList bilan deyarli birxil amalga oshiriladi.










  1. import java.util.*;

  2. public class TestCollection7{

  3.  public static void main(String args[]){



  4. LinkedList al=new LinkedList();

  5. al.add("Zafar");

  6. al.add("Aziz");

  7. al.add("Jalol");

  8. al.add("Zafar");



  9. Iterator itr=al.iterator();

  10. while(itr.hasNext()){

  11. System.out.println(itr.next());

  12. }

  13.  }

  14. }

ArrayList saqalagan ma’lumotlarni LinkedList ham saqlashi mumkun

LinkedListda gi ma’lumotlarni ArrayListga qo’shib qo’yishga misol


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class ConvertExample {


public static void main(String[] args) {
LinkedList linkedlist = new LinkedList();
linkedlist.add("Zafar");
linkedlist.add("Aziz");
linkedlist.add("Jalol");
linkedlist.add("Fayzullo");

List list = new ArrayList(linkedlist);


for (String str : list){


System.out.println(str);
}
}
}

Download 1.25 Mb.

Do'stlaringiz bilan baham:
1   ...   36   37   38   39   40   41   42   43   ...   49




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling