📋 Lists & Arrays
List Fundamentals
Add, remove, access — the everyday bread-and-butter operations
The essential operations on dynamic arrays (Python list, JS Array, Java ArrayList, Go slice, C++ vector).
Language:
Python
Loading...
All languages — Create & fill
JavaScript
// Leer
const nums = [];
// Mit Werten
const nums2 = [1, 2, 3];
// Vorgefüllt (5 Nullen)
const zeros = new Array(5).fill(0); // [0,0,0,0,0]
// 2D (3×3 Matrix)
const matrix = Array.from({ length: 3 }, () => new Array(3).fill(0));TypeScript
const nums: number[] = [];
const nums2: number[] = [1, 2, 3];
const zeros: number[] = new Array(5).fill(0);
const matrix: number[][] = Array.from({ length: 3 }, () => new Array(3).fill(0));Java
// Array (feste Größe):
int[] arr = new int[5]; // [0,0,0,0,0]
int[] arr2 = {1, 2, 3};
// ArrayList (dynamisch):
List<Integer> list = new ArrayList<>();
List<Integer> list2 = new ArrayList<>(Arrays.asList(1, 2, 3));Go
// Slice (dynamisch):
var nums []int // nil slice
nums2 := []int{1, 2, 3}
// Vorgefüllt:
zeros := make([]int, 5) // [0,0,0,0,0]
// 2D:
matrix := make([][]int, 3)
for i := range matrix {
matrix[i] = make([]int, 3)
}C++
// Array (feste Größe):
int arr[5] = {}; // {0,0,0,0,0}
// Vector (dynamisch):
vector<int> nums;
vector<int> nums2 = {1, 2, 3};
// Vorgefüllt:
vector<int> zeros(5, 0); // {0,0,0,0,0}
// 2D:
vector<vector<int>> matrix(3, vector<int>(3, 0));