if we don't assign value to an integer array or (primitive types) the default value assigned is 0.
If we don't assign value to the string array by default the value is “null”. it is a literal like none in Python.
string str = null; is correct
int a = null; is wrong
a primitive type is eg an integer, a character that cannot be broken down.
Data Types-
at compile time variable is created in stack memory and on run time memory is allocated in heap memory with the initialized size value.
Mutable objects = Values can be re-assigned post initialization. eg- arrays, lists, dictionaries
Immutable objects= cannot be re-assigned or changed once created. eg- tuples, strings.
2D-arrays- rows are manadatory as in heap it is stored as arrays inside array, In 2D array arrays are stored inside array.
each object inside array is a reference variable pointing to an object, just like arr pointing to array.
####size of row = array.length,
###size of col = row[i].length.
###2d array
- psudo code- how to fill this array’s rows and columns-
define arrays length - int [][] arr1 = new int [3][2]
define for loop- till how many rows to fill = for(int i=0; i<arr1.length; i++)
define for loop - how many cols to fill within each row = for(int j =0; j<arr[i].length; j++)
working of loop- for each row(or i), iterating (all)each column inside, and filling the 2d array.
Subscribe to my newsletter
Read articles from directly inside your inbox. Subscribe to the newsletter, and don't miss out.
SUBSCRIBE
WRITTEN BY
Shivani Paswan
©2023 Shivani Paswan's Blog
Powered by Hashnode - Home for tech writers and readers