Day 10 – Learning Java Full Stack Today let's learn about While Loop. The while loop is used when we want to execute a block of code repeatedly as long as a condition is true. Syntax: while (condition) { // loop body } The loop keeps running until the condition becomes false. Example: int a = 1; while (a <= 5) { System.out.println("JAVA"); a++; } Execution Flow: When a = 1 → JAVA When a = 2 → JAVA When a = 3 → JAVA When a = 4 → JAVA When a = 5 → JAVA When a = 6 → Condition becomes false → Loop terminates Key takeaway: A while loop is condition-based repetition. If the condition never becomes false, it can lead to an infinite loop — so updating the variable is very important. More learning updates coming soon #Java #JavaFullStack #WhileLoop #ControlStatements #LearningInPublic #CoreJava
Java While Loop Basics: Condition-Based Repetition
More Relevant Posts
-
🚀 Day 4 of My Java Learning Journey Today I learned how a Java program works internally and covered some important core concepts. 📌 Topics I Covered: 🔹 How to run a Java program • Compile using javac • Run using java • JVM executes the program 🔹 Main Method in Java public static void main(String[] args) • public → JVM can access it from anywhere • static → No need to create object • void → Does not return any value • main → Entry point of program 🔹 System.out.println() • System → class from java.lang package • out → object of PrintStream • println() → method used to print output 🔹 Variables in Java • A variable is a container to store data in memory (RAM) • Syntax: datatype variable_name = value; Example: int age = 35; System.out.println("The age is: " + age); 📌 Rules of Variables • Cannot contain spaces • Cannot start with a digit • Can use _ and $ symbols Building strong fundamentals in Java step by step and staying consistent every day. You can check my code here 👇 🔗 https://lnkd.in/gDP4A9r6 If you are also learning Java, let’s connect and grow together 🤝 #Java #JavaDeveloper #CodingJourney #Programming #LearningInPublic #SoftwareDevelopment
To view or add a comment, sign in
-
-
Day 12 – Learning Java Full Stack. Today’s topic was one of the most important concepts in Java — Methods. A method is a named block of reusable code that performs a specific task. Instead of writing the same logic again and again, we can define it once and call it whenever needed. Structure of a Method- Creating a method involves two parts: 1️⃣ Method Declaration 2️⃣ Method Definition General Syntax: access_modifier modifier return_type methodName(arguments) { // method body } Key Points to Learn: A method must be declared inside a class A method executes only when it is called The same method can be called multiple times A class can contain multiple methods Methods improve modularity and reusability They make programs easier to read, maintain, and modify. 📌 Key Takeaway: Methods are the foundation of structured programming. Without methods, building scalable applications would be difficult. #Java #JavaFullStack #MethodsInJava #ProgrammingBasics #LearningInPublic #CoreJava
To view or add a comment, sign in
-
-
Day 11 – Learning Java Full Stack. Today’s let's learn about Do-While Loop. The do-while loop is similar to the while loop, but with one important difference — "it executes the loop body at least once, even if the condition is false." Syntax: do { // do-while body } while (condition); Example: int a = 1; do { System.out.println("JAVA"); a++; } while (a <= 5); Execution Flow: When a = 1 → JAVA When a = 2 → JAVA When a = 3 → JAVA When a = 4 → JAVA When a = 5 → JAVA When a = 6 → Condition becomes false → Loop exits Difference Between while and do-while ✔ while loop Condition is checked first May execute zero times Entry-controlled loop ✔ do-while loop Executes body first Condition checked later Executes at least once Exit-controlled loop. All the problems I solved are available in my GitHub repository: https://lnkd.in/gy-j_Qfb 📌 Key takeaway: Use while when you need to check the condition before execution. Use do-while when the code must run at least once. More learning updates coming soon. #Java #JavaFullStack #DoWhileLoop #ControlStatements #LearningInPublic #CoreJava
To view or add a comment, sign in
-
-
🌱 Learning the Basics of OOP in Java While learning Java, I understood that Object-Oriented Programming (OOP) is built on 4 simple but powerful concepts: 🔹 1. Inheritance One class can use properties and methods of another class. 👉 This helps in reusing code. 🔹 2. Encapsulation Keeping data safe by wrapping variables and methods inside a class. 👉 We use private variables and getters/setters for security. 🔹 3. Polymorphism One method can behave differently in different situations. 👉 Example: Method overloading and method overriding. 🔹 4. Abstraction Showing only important details and hiding internal implementation. 👉 Done using abstract classes and interfaces. Understanding these concepts makes Java much clearer and helps in building real-world applications. I’m currently improving my Java fundamentals step by step. Every small concept I learn gives me more confidence. 💪 #Java #OOP #ProgrammingBasics #LearningJava #BeginnerDeveloper #SoftwareDevelopment
To view or add a comment, sign in
-
-
💡 Java Learning Series – final vs finally vs finalize These three terms sound similar in Java but have completely different purposes. Here’s a simple breakdown: ✔️ final – A keyword used to restrict modification. → Final variable = constant value → Final method = cannot be overridden → Final class = cannot be inherited ✔️ finally – A block used in exception handling. → Always executes whether an exception occurs or not → Commonly used for closing resources like files or database connections ✔️ finalize() – A method called by the garbage collector before object destruction (now rarely used and mostly deprecated in modern Java). Understanding these small differences helps avoid confusion and write better Java code.🚀 #Java #CoreJava #Programming #JavaDeveloper #CodingJourney #LearningJava
To view or add a comment, sign in
-
🚀 Learning Java the Right Way Today, I practiced an important Java concept 👉 Exception Handling. 📌 Problem: Create a Java program that performs division and properly handles the case when a user tries to divide a number by zero. Instead of letting the program crash, I used try–catch–finally blocks to manage the error gracefully. 🔹 Key Learning: try → Code that may cause an exception catch → Handles the exception (like Arithmetic Exception) finally → Executes important code regardless of exception Example scenario: If a user enters 0 as the divisor, Java throws an Arithmetic Exception, which can be handled to prevent program failure. This concept helped me understand: ✔ Runtime error handling ✔ Writing safer and more reliable programs ✔ Improving application stability Proper exception handling is essential for building robust and production-ready software. 📌 Write safe code • Handle errors smartly • Build reliable applications 💡 #java #javafullstack #javadeveloper #corejava #codingjourney #coding
To view or add a comment, sign in
-
-
While learning more about constructors in Java, the idea of a default constructor also became clearer. A default constructor is automatically provided by Java when no constructor is written in a class. Things that became clear : • if a class does not define any constructor, Java automatically creates a default constructor • the default constructor has no parameters • it mainly helps create objects without requiring initialization values • instance variables get their default values if they are not explicitly initialized • once a constructor is written manually, Java no longer provides the default one automatically A simple example shows how it works : class Student { int rollNo; String name; } public class Test { public static void main(String[] args) { Student s = new Student(); System.out.println(s.rollNo); System.out.println(s.name); } } Here, even though no constructor is written, Java still allows object creation by providing a default constructor. Understanding this behaviour helps explain why objects can still be created even when constructors are not explicitly defined. #java #oop #programming #learning #dsajourney
To view or add a comment, sign in
-
Day 28 -What I Learned in a Day(JAVA) Today I started learning Looping Statements in Java. Loops are used to execute a block of code repeatedly until a certain condition becomes false. They help reduce code repetition and make programs more efficient. In Java, there are mainly three types of loops: • while loop • do-while loop • for loop Today I focused on the while loop. 🔹 What is a While Loop? A while loop executes a block of code repeatedly as long as the condition is true. The condition is checked before the loop executes, so if the condition is false initially, the loop will not run. Syntax of While Loop: initialization; while(condition) { // statements increment / decrement; } What I Practiced Today: ✔ Practiced 3 basic while loop programs ✔ Built a calculator program using while loop and switch statement ✔ Learned how loops control program flow and reduce repetitive code Every day I’m taking small steps to improve my Java programming skills and strengthen my understanding of core concepts. Practiced 👇 #Java #JavaLearning #Programming #CodingJourney #Loops #WhileLoop
To view or add a comment, sign in
-
Day 4 of Java Fundamentals 🚀 Today I revised the Inheritance in Java. Inheritance allows a class to acquire properties and methods of another class. Benefits: ✔ Code reusability ✔ Reduced duplication ✔ Better code structure Example: Dogs inherit behavior like eat() from Animal. 🔹 Multiple Inheritance in Java Java does not support multiple inheritance using classes to avoid complexity (diamond problem). However, it can be achieved using interfaces. 🔹 What is an Interface? An interface is a blueprint that contains abstract methods. A class can implement multiple interfaces, allowing Java to achieve multiple inheritance in a safe way. Example: A class can implement both Printable and Scannable interfaces. Learning Java fundamentals step by step to strengthen my core concepts 💻 #Java #LearningInPublic #SoftwareDevelopment #JavaDeveloper
To view or add a comment, sign in
-
DAY 16: CORE JAVA TAP Academy 🚀 Deep Dive into Java Strings: Memory, Methods, and Manipulation If you're learning Java, you quickly realize that Strings aren't just simple data types—they are objects with unique memory management rules! I’ve been brushing up on the fundamentals and mapped out some key concepts. Here’s a breakdown of what I’ve been diving into: 🧠 1. String Memory Management The difference between SCP (String Constant Pool) and the Heap is crucial for performance: * Direct Literals: Using "A" + "B" creates the string in the SCP. No duplicates allowed! * Variables/Objects: Concatenating variables (e.g., s1 + s2) or using the concat() method always creates a new object in the Heap. * The Result: Two strings can have the same value but different memory references. This is why we use .equals() for content and == for reference! 🛠️ 2. Essential String Methods Java provides a robust toolkit for string manipulation. Some of my favorites from today’s practice: * substring(start, end): To extract specific parts of a string. * indexOf() & lastIndexOf(): To track down character positions. * toCharArray() & split(): Perfect for breaking strings down for complex algorithms. ⚖️ 3. Mastering compareTo() Unlike .equals() which just gives a True/False, compareTo() returns an integer based on Lexicographical order: * Negative: s1 < s2 (comes before) * Positive: s1 > s2 (comes after) * Zero: They are a perfect match! Understanding these nuances is the first step toward writing memory-efficient Java code. #Java #Programming #CodingTips #SoftwareDevelopment #LearningToCode #TechCommunity #JavaStrings
To view or add a comment, sign in
-
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