ArrayList, LinkedList, Vector In Hindi

ArrayList, LinkedList, Vector In Hindi

जावा प्रोग्रामिंग में ArrayList, LinkedList, और Vector सभी डाटा टाइप जावा में एक बिल्ट-इन एलिमेंट फ्रेमवर्क का इम्पोर्टेन्ट एलिमेंट हैं, जो की जावा प्रोग्रामर को लिस्ट में डाटा टाइप एलिमेंट स्ट्रक्चर इंटरफ़ेस को अप्लाई करने में हेल्प करते हैं। जावा में ArrayList, LinkedList, और Vector क्लास डाटा टाइप का सामान्य रूप से यूज़ क्लास ऑब्जेक्ट डाटा टाइप के ग्रुप एलिमेंट को स्टोर, प्रोसेस, और मैनिपुलेट करने में हेल्प करते है। यहाँ ArrayList, LinkedList, और Vector डाटा टाइप में कुछ सिमिलर फीचर्स एंड फंक्शन होने के बाद भी, इनमें डिफाइन डिक्लेअर हर क्लास डाटा टाइप के अपने इंडिविजुअल फीचर्स फंक्शन और स्पेशल यूज़ के अनुसार भिन्न भिन्न होते हैं।

ArrayList, LinkedList, Vector In Hindi

ArrayList Data Type in Java.

जावा प्रोग्रामिंग में ArrayList डाटा टाइप लिस्ट डाटा टाइप इंटरफ़ेस में एक रिसाइज़ेबल स्ट्रक्चर है, जिसे जरूरत पड़ने पर रीसाइज किया जा सके और यह एक ArrayList को प्रॉपर इम्प्लीमेंटेशन करने का मेथड है। ArrayList जावा लाइब्रेरी में java.util पैकेज का बिल्ट-इन फीचर्स है, और यह ऐरे डाटा टाइप जैसे जावा यूजर को स्टोर डाटा एलिमेंट वैल्यू इंडेक्स के अनुसार ऐरे स्टोरेज एलिमेंट तक फ़ास्ट रैंडम एक्सेस प्रोवाइड करता है। जैसा की, ArrayList जावा यूजर को ऐरे डाटा को डायनामिक रिसाइज़िंग फीचर्स प्रोवाइड करता है, इसका मतलब है कि मौजूदा ArrayList डाटा टाइप में एक नया एलिमेंट ऐड या रिमूव करने पर लिस्ट डाटा टाइप का साइज़ अपने आप बढ़ या घट सकता है।

Features of the ArrayList Data Type.

  • Resizing – जब किसी ArrayList डाटा टाइप में डिक्लेअर लिस्ट डाटा अपनी फिक्स डिक्लेअर कैपेसिटी को हाशिल कर लेता है, तो यहाँ ArrayList डाटा टाइप जरूरत पड़ने पर ऑटोमैटिकली रिसाइज़ हो जाता है।
  • Random Access – ArrayList जावा प्रोग्राम में स्टोरेज इंडेक्स (O(1) टाइम कॉम्प्लेक्सिटी) के अनुसार यूजर को ArrayList डाटा टाइप एलिमेंट तक कॉन्स्टेंट-टाइम एक्सेस प्रोवाइड करता है।
  • Efficient for retrieval – ArrayList जावा में कुछ पर्टिकुलर कंडीशन के लिए सबसे बेस्ट है, जहाँ जावा यूजर को ज्यादातर ArrayList एलिमेंट को एक्सेस करने की ज़रूरत होती है. इस प्रोसेस में जावा यूजर मल्टीप्ल टाइम ArrayList डाटा इंसर्शन या डिलीशन ऑपरेशन को अप्लाई नहीं कर सकते हैं।

Instance of the ArrayList Data Type.

import java.util.ArrayList;

public class ArrayListDataType {

    public static void main(String[] args) {

        ArrayList<String> list = new ArrayList<>();

        // here we manually Adding the ArrayList elements

        list.add(“Java”);

        list.add(“Javascript”);

        list.add(“Python”);

        list.add(“Sql”);

        // here it Accessing the ArrayList elements storage location

        System.out.println(“Storage Element index location 3 is – ” + list.get(3)); // Result – Sql

        // here it Iterating through the all ArrayList element

        for (String language : list) {

            System.out.println(language);

        }

        // now we remove the element of the array list

        list.remove(“Javascript”);

        System.out.println(“After ArrayList element deletion – ” + list);

    }

}

LinkedList data type in Java.

जावा प्रोग्रामिंग में लिंक्डलिस्ट डाटा टाइप जावा यूजर को एक लिस्ट स्टोरेज एलिमेंट इंटरफ़ेस का एक डबल लिंक्ड लिस्ट स्टोरेज डाटा वैल्यू एलिमेंट स्ट्रक्चर प्रोवाइड करता है। लिंक्डलिस्ट डाटा टाइप java.util पैकेज लाइब्रेरी का एक बिल्ट-इन फीचर्स है. यह जावा यूजर द्वारा अप्लाई लिंक्डलिस्ट डाटा टाइप एलिमेंट्स में नई एलिमेंट को इन्सर्ट और रिमूव करने के लिए बेहतर परफॉर्मेंस प्रोवाइड करता है. विशेष रूप से, जब लिंक्डलिस्ट डाटा टाइप ऑपरेशन लिस्ट के स्टार्ट या मिडिल में परफॉर्म हो।

LinkedList data type in Java.

  • Linked Structure – जावा प्रोग्राम में डिक्लेअर यूज़ लिंक्डलिस्ट डाटा टाइप में हर एलिमेंट एक नोड के रूप में डिफाइन होता है, जिसमें लिंक्डलिस्ट डाटा को एक्सेस करने के लिए डेटा के नेक्स्ट और प्रीवियस एलिमेंट्स के रेफरेंस एड्रेस स्टोर होते हैं।
  • Insertions and Deletions – लिंक्डलिस्ट डाटा टाइप लिस्ट के स्टार्ट या मिडिल में (O(1) टाइम कॉम्प्लेक्सिटी) में नई डाटा नोड इन्सर्ट और एक्सिस्टिंग डाटा नोड डिलीशन करते समय एफिशिएंट चॉइस है।
  • Slow Random Access – जावा लिंक्डलिस्ट डाटा टाइप में इंडेक्स (O(n) टाइम कॉम्प्लेक्सिटी) के अनुसार लिस्ट डाटा वैल्यू एलिमेंट्स तक स्लो एक्सेस होता है, क्योंकि इस प्रोसेस में यूजर को लिस्ट में से पूरा स्टार्ट तो एंड तक गुजरना पड़ता है।
  • Not synchronized – जावा में यूज ArrayList डाटा टाइप के जैसे ही, लिंक्डलिस्ट डाटा टाइप डिफ़ॉल्ट रूप से थ्रेड-सेफ प्रोसेस नहीं है।

Example of the LinkedList data type.

import java.util.LinkedList;

public class LinkedListDataType {

    public static void main(String[] args) {

        LinkedList<String> list = new LinkedList<>();

        // here we manaully Adding the LinkedList Data Type node elements

        list.add(“Laptop”);

        list.add(“Desktop”);

        list.add(“Palmtop”);

        list.add(“Ultrabook”);

        // here we Accessing the LinkedList first elements

        System.out.println(“Here is the First element of LinkedList – ” + list.getFirst()); // Result – Laptop

        // now we Adding an element at the beginning of LinkedList

        list.addFirst(“Mackbook”);

        // here we Adding an last element at the end of LinkedList

        list.addLast(“Apple Imac”);

        // here it Iterating through the completer LinkedList element node

        for (String computer : list) {

            System.out.println(computer);

        }

        // here we Removing the LinkedList element

        list.remove(“Desktop”);

        System.out.println(“After LinkedList element removal – ” + list);

    }

}

Vector data type in Java.

जावा प्रोग्रामिंग में यूज़ एक वेक्टर डाटा टाइप ArrayList डाटा टाइप की तरह ही स्ट्रक्चर या डिफाइन होता है,  जैसा की इसमें कुछ स्पेशल डिफ्रेंस भी होते हैं। वेक्टर डाटा टाइप भी आपको List डाटा टाइप इंटरफ़ेस की तरह एक डायनामिक ऐरे इम्प्लीमेंटेशन मेथड प्रोवाइड करता है, और वेक्टर डाटा टाइप java.util लाइब्रेरी पैकेज का एक बिल्ट-इन फीचर्स है। वेक्टर डाटा टाइप ArrayList के अपोजिट, वेक्टर डाटा का नेचर सिंक्रोनाइज़्ड आर्डर में होता है, जिससे की यह थ्रेड-सेफ़ हो जाता है। जैसा की, प्रोग्राम में यूज़ सिंगल-थ्रेडेड एप्लिकेशन में इस सिंक्रोनाइज़ेशन की परफ़ॉर्मेंस कॉस्ट की जाती है।

Features of the Vector data type.

  • Thread-safety – जावा में यूज़ वेक्टर डाटा टाइप सिंक्रोनाइज़्ड नेचर का होता है, जिससे की यह यूज़ में थ्रेड-सेफ हो जाता है। जैसा की, यह प्रोसेस सिंक्रोनाइज़ेशन में इसे सिंगल-थ्रेडेड एनवायरनमेंट में स्लो कर सकता है।
  • Resizing – वेक्टर डाटा टाइप ArrayList की तरह ही ऑटोमैटिकली अपने साइज़ बदल सकता है, लेकिन जब ऐरे डाटा टाइप फुल हो जाता है. तो यह सामान्यता रूप से साइज़ में डबल हो जाता है. जिससे की इसके स्टोरेज लोकेशन में ज़रूरत से ज़्यादा मेमोरी का यूज़ होता है।
  • Outdated – जावा प्रोग्राम में यूज़ वेक्टर डाटा टाइप को इसके सिंक्रोनाइज़ेशन ओवरहेड प्रोसेस के कारण कुछ हद तक ओल्ड डाटा टाइप के रूप में ट्रीट किया जाता है, और मोस्ट ऑफ़ केसेस में, ArrayList डाटा टाइप को रिकमेंड या यूज़ किया जाता है. जब तक कि इनमे थ्रेड-सेफ्टी प्रायोरिटी डिफाइन न हो।

Example of the Vector data type.

import java.util.Vector;

public class VectorDataType {

    public static void main(String[] args) {

        Vector<String> vector = new Vector<>();

        // here we Adding a manual Vector data type elements

        vector.add(“Rust”);

        vector.add(“Matlab”);

        vector.add(“Ruby”);

        vector.add(“Swift”);

        // here we Accessing the Vector elements

        System.out.println(“Here we access the vector Element at index location 2 – ” + vector.get(2)); // Output: Ruby

        // here it Iterating through the Vector list

        for (String language : vector) {

            System.out.println(language);

        }

        // here we Removing the vector element

        vector.remove(“Matlab”);

        System.out.println(“After removal vector element – ” + vector);

    }

}

Difference between ArrayList, LinkedList, and Vector.

Each FeatureArrayList data typeLinkedList data typeVector data type
How to ImplementationIt nature is Dynamic array, which increase and decrease  automaticallyIt works like Doubly linked list in booth sideIt supports Dynamic array process mechanism
Use Performance (Random Access/ or notArraylist allow Fast (O(1)) indexing accessLinkedList allow Slow (O(n)) indexing accessVector data type allows Fast (O(1)) indexing access
Operation Performance (data Insertion/or Deletion)In Arraylist data type Slow for beginning/middle (O(n)) insertion and deletion operationIn LinkedList Fast for beginning/middle (O(1)) insertion and deletion processIn vector data type Slow for beginning/middle (O(n)) insertion and deletion process
How to ResizingArraylist data type Doubles in size when it fullLinkedList data type Can grow dynamicallyvector data type Doubles in size when it full
Thread Safety featuresArraylist data type is Not synchronizedLinkedList data type is Not synchronizedvector data type Synchronized (thread-safe)
Where to Use CaseArraylist data type Best for random data access, moderate insertionsLinkedList data type Best for frequent insertions/removalsvector data type Used when thread safety is important
How much Memory UsageArraylist data type Generally uses the less memoryLinkedList data type Uses more memory due to linked structurevector data type Uses more memory due to doubling size on resize

ArrayList, LinkedList, and Vector are all list data type summaries.

  • ArrayList – जावा में ArrayList डाटा टाइप का यूज़ तब किया जाता है, जब जावा यूजर को इंडेक्स लोकेशन के अनुसार फ़ास्ट एक्सेस की ज़रूरत हो या आपको कम डाटा इंसर्शन या डिलीशन करना हों. स्पेशली, जब आपको ग्रुप डाटा साइज़ कम मॉडिफाई होता हो।
  • LinkedList – जावा में LinkedList डाटा टाइप को यूज़ तब करें, जब जावा यूजर को मल्टीप्ल टाइम एलिमेंट नोड इंसर्शन या डिलीशन करने की ज़रूरत हो. स्पेशली, LinkedList के स्टार्ट या मिडिल पोजीशन में। उस तरह की पर्टिकुलर कंडीशन के लिए इससे बचें जिनमें इंडेक्स के हिसाब से फ़ास्ट डाटा एक्सेस की ज़रूरत हो।
  • Vectorजावा प्रोग्राम में Vector डाटा टाइप सिंक्रोनाइज़ेशन ओवरहेड के कारण ज़्यादातर मॉडर्न एप्लिकेशन में Vector डाटा टाइप का इस्तेमाल न करे। यदि आपको किसी एप्लीकेशन में थ्रेड-सेफ्टी फीचर्स चाहिए। तो आप ArrayList या CopyOnWriteArrayList जैसे दूसरे थ्रेड-सेफ स्ट्रक्चर का प्रोग्राम में यूज़ कर सकते है।

Leave a Reply