int rollno = 101; // 'int' is a data type for integers
String name = "deepak"; // 'String' is a non-primitive data type for text
int[] marks = {85, 90, 78}; // 'int[]' is an array to store multiple integers
Click Here to read Primitive Data Types deeply.
String name = "Deepak";
String name = "deepak"; // Allocates 12 bytes for storage (1 char size is 2 byte and total there are 6 characters)
ArrayList
grows dynamically as elements are added.
ArrayList numbers = new ArrayList<>();
numbers.add(10); // Memory adjusts as elements are added.
String unused = new String("Garbage");
unused = null; // The memory for "Garbage" is now eligible for garbage collection.
Your feedback helps us grow! If there's anything we can fix or improve, please let us know.
Weโre here to make our tutorials better based on your thoughts and suggestions.