Day 9 of Learning Java, From Single Values to Collections 📦 Till now, I was storing one value at a time. Today? I learned how to store many values together. 👉 Arrays. Because creating 100 separate variables? That’s chaos. Arrays = Organized memory. 🔥 1D Array Store multiple values in one variable. And yes… Java arrays start from index 0 (important!). 📊 2D & 3D Arrays Now things feel next level. 2D → Like a table (rows & columns). 3D → Data inside layers. Accessing elements with: arr[i][j] arr[i][j][k] Now I can literally structure data properly. 🔁 Traversal Using loops to go through each element. This is where loops + arrays connect perfectly. 💬 Introduction to Strings String str = "Hello"; Not just text… But a sequence of characters stored in memory. Big realization today? Arrays make code scalable. Clean structure = clean thinking. Day 9 and now my code can handle real data 🚀🔥 Big thanks to Aditya Tandon sir and Rohit Negi sir #Java #CoreJava #Arrays #Programming #LearningJourney #Developers
Learning Java Arrays: Organized Memory for Scalable Code
More Relevant Posts
-
✨DAY-6: 💻 Understanding Variables in Java – So Many Possibilities! 🚀 Every Java journey starts with one powerful concept — Variables. This fun meme reminds us that variables are the foundation of programming. They help us store, manage, and manipulate data efficiently. 🔹 int x = 10; → Stores whole numbers 🔹 double y = 5.5; → Stores decimal values 🔹 boolean isJavaFun = true; → Stores true/false 🔹 String name = "SpongeBob"; → Stores text 🔹 char grade = 'A'; → Stores a single character ✨ Variables are like containers — choose the right type, and your program becomes cleaner and more efficient. Before learning advanced concepts like OOP, Collections, or Spring Boot, mastering variables and data types is essential. Strong fundamentals build strong developers 💪 #Java #CoreJava #Variables #Programming #CodingJourney #JavaDeveloper #LearningEveryday #DevelopersLife
To view or add a comment, sign in
-
-
Day 10 of Java & Now I Know Where My Array Actually Lives 🧠💻 Today was not about writing arrays… It was about understanding what happens inside memory. And honestly this was powerful. 👉 Arrays are non-primitive (reference) types. That means: When we write int[] arr = new int[5]; • The variable arr lives in Stack memory • The actual array data lives in Heap memory • arr stores the reference (address) of that heap location So basically… We’re pointing to memory. 🔥 Contiguous Storage Array elements are stored next to each other in one continuous block. 5 integers = 5 × 4 bytes = 20 bytes All in one straight line. That’s why arrays are fast. ⚡ Random Access Java doesn’t search for elements. It calculates their address: Base Address + (Index × Size of Data Type) That’s why accessing the 1st element takes the same time as the 1,000,000th. O(1) access. Instant. Big realization today? Arrays aren’t just collections. They’re structured memory blocks optimized for speed. Day 10 and now I’m not just using arrays… I understand how they work internally. Leveling up every day 🚀🔥 Special thanks to Rohit Negi sir and Aditya Tandon sir🙌🏻🙌🏻 #Java #CoreJava #Arrays #Programming #LearningJourney #Developers #BuildInPublic
To view or add a comment, sign in
-
-
💡 Why does System.out.print(); sometimes give a compile-time error? While learning Java, you might write something like this: System.out.println("A"); System.out.print(); System.out.println("X"); and get a compile-time error. Why does this happen? 🤔 ✔️ The reason: System.out.print(); prints output without moving to a new line, but this method requires an argument. When you leave it empty, the compiler doesn’t know what it should print, so it throws a compile-time error. In simple words 👉 print() must be given something to print. ✔️ How to fix it: 📍 If you want a blank line: System.out.println(); 📍 If you want to print a space: System.out.print(" "); Small mistakes like this help us understand how Java methods really work 💻✨ What other small Java mistakes helped you understand programming better? Drop them in the comments 👇 #Java #Programming #LearningJava #CodingBasics #SoftwareEngineering
To view or add a comment, sign in
-
-
Another concept that appears when working with constructors is constructor overloading. It allows a class to have multiple constructors so that objects can be created in different ways depending on the information available. Things that became clear : • constructor overloading means having multiple constructors in the same class • each constructor must have a different parameter list • it allows objects to be initialized with different sets of values • Java decides which constructor to use based on the arguments passed during object creation • it helps make classes more flexible and easier to use A simple example shows how different constructors can be used : class Student { String name; int age; Student() { System.out.println("Default constructor"); } Student(String name, int age) { this.name = name; this.age = age; } } In this case, objects can be created either without values or with specific values depending on which constructor is called. Understanding constructor overloading made it clearer how classes can support different ways of creating objects. #java #oop #programming #learning #dsajourney
To view or add a comment, sign in
-
♻️ Why should you always close Scanner in Java? Scanner is used to read input, from the console, a file, or a stream. But a lot of beginners (including me, early on) never bother closing it after use. Here's why that's a problem: ->it holds onto system resources even after your program is done with them ->for file-based Scanners, it can lock the file or cause data not to be flushed properly ->in larger programs, unclosed Scanners can quietly lead to resource leaks The fix is simple, either call: ✔️ sc.close() at the end ✔️ or use a try-with-resources block so Java closes it automatically While practicing Java basics, I realized the code worked either way… but one way was responsible, and the other wasn't. That's something no compiler warning will tell you. Writing correct code and writing clean, responsible code are two different things. Learning the difference early makes you a better developer. Learning in public, improving step by step 🤍 #Java #ResourceManagement #LearningInPublic #Programming
To view or add a comment, sign in
-
Day - 21 : Copy on write Arraylist Copy on write means that whenever a write operation like adding or removing an element, without directly modifying the existing list. A new copy of the list is created , and the modification is applied to that copy.This ensures that other threads reading the list while it's being modified are unaffected. Example : List<String> shoppinglist = new CopyOnWriteArraylist<>(); shopping.add("Egg"); shopping.add("Fruit"); System.out.println("Initial shopping " +shoppinglist); for( String item : shoppinglist){ System.out.println(item); } if(item.equals("Egg")){ shoppinglist.add("Butter"); } } System.out.println("updated shoppinglist " +shoppinglist); } } #java #backend #programming #learning #Corejava EchoBrains
To view or add a comment, sign in
-
-
🚀 Day 8 of My Core Java Journey Today I learned about Loops & Jump Statements in Java, which are fundamental for controlling iterations and repeating tasks in programs. 🔁 Loops Covered: ➤ While Loop – Check first, then execute ➤ Do-While Loop – Execute first, then check (runs at least once, useful in menu-driven programs) ➤ For Loop – All-in-one powerful loop for initialization, condition, and update 🔄 Also explored: ✔ Nested loops and how iterations grow (n × m pattern) ✔ How loops control execution flow step by step ⚡ Jump Statements: ➤ break → stops the loop immediately ➤ continue → skips the current iteration 💡 Bonus Learning: • We can use labeled loops (outer, inner) for better control in nested loops • Understanding loop flow makes it easier to optimize logic and avoid unnecessary iterations This topic made it clear how programs handle repetition and control flow efficiently. Grateful to Rohit Negi sir, Aditya Tandon sir, and the Coder Army youtube channel for such clear explanations 🙌 Building strong Core Java fundamentals step by step 💻 #Java #CoreJava #JavaDeveloper #Programming #Loops #LearningJourney #CoderArmy
To view or add a comment, sign in
-
-
Another important concept while working with classes in Java is the constructor. Constructors are closely related to object creation and help initialize the data inside an object. Things that became clear : • a constructor is a special method used to initialize objects • it has the same name as the class • constructors do not have a return type • they are called automatically when an object is created • they are commonly used to set initial values for instance variables A simple example helps illustrate the idea : class Employee { String name; int age; Employee() { System.out.println("Constructor called"); } } Whenever an object of the class is created, the constructor runs automatically and prepares the object for use. Understanding constructors made it clearer how Java ensures that objects start with proper initial values. #java #oop #programming #learning #dsajourney
To view or add a comment, sign in
-
Another small but interesting concept while studying interfaces was marker interfaces. Unlike normal interfaces, marker interfaces do not define any methods. Instead, they act as a signal to the Java runtime that a class has a certain capability. Things that became clear : • marker interfaces are empty interfaces without methods • they are used to "mark" a class so that the JVM treats it differently • they provide additional behaviour without forcing method implementation • some well-known examples in Java include Cloneable and Serializable • they are mainly used by libraries or the runtime to enable certain features A simple structure looks like this : interface IDemo { } class Test implements IDemo { } Here the interface itself does not contain any methods, but implementing it can allow a class to receive special handling in certain situations. Understanding marker interfaces showed another way Java uses interfaces beyond just defining behaviour. #java #oop #programming #learning #dsajourney
To view or add a comment, sign in
-
Day 10/100 — Scanner User Input in Java ⌨️ One common issue every Java beginner faces while taking user input using the Scanner class. ⚠️ The nextLine() bug after nextInt() When we use nextInt() and then immediately call nextLine(), the nextLine() may get skipped. This happens because nextInt() does not consume the newline character left in the input buffer. ✔️ Solution: Add an extra sc.nextLine() to clear (flush) the buffer. Example: Scanner sc = new Scanner(System.in); System.out.print("Enter your marks: "); int marks = sc.nextInt(); sc.nextLine(); // flush the leftover newline System.out.print("Enter your name: "); String name = sc.nextLine(); 💻 Challenge I worked on today: Build a simple Report Card program that takes student details and marks using Scanner input. Step by step learning — improving Java fundamentals every single day 🚀 #Java #CoreJava #Scanner #JavaLearning #Programming #100DaysOfCode
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development