Difference between Java and Python - Part 2
Автор: notesforimpact
Загружено: 2026-01-17
Просмотров: 5
Difference in Java and Python - [Basics] - Part 2
Description:
This is a continuation video of Part 2 . In the previos video we discussed about the collection methods in Java . In this video we will be discussing on the below points as how are they different in Python
ArrayList (Ordered, Allows Duplicates)
add(element): Appends the element to the end of the list.
add(index, element): Inserts an element at a specific index, shifting others.
get(index): Retrieves the element at the given index.
set(index, element): Replaces the element at the specified index.
remove(element) / remove(index): Removes the first occurrence of an element or the element at an index.
size(): Returns the number of elements.
Set (Unordered, No Duplicates)
add(element): Adds the element if it's not already present; returns true if added, false if not.
remove(element): Removes the specified element.
contains(element): Checks if the set contains the element.
clear(): Removes all elements.
Map (Key-Value Pairs, Unique Keys)
put(key, value): Adds or updates a key-value pair; keys must be unique.
get(key): Retrieves the value associated with the key.
remove(key): Removes the key-value pair for the given key.
containsKey(key): Checks if the map contains the key.
size(): Returns the number of key-value pairs.
Key Differences
ArrayList: Indexed, ordered, allows duplicates (like a dynamic array).
Set: No index, unordered (typically), no duplicates (for unique data).
Map: Stores key-value pairs, unique keys for fast lookups (not a list of items).
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: