Day 9/100 — Math Class & Type Casting in Java 🔢 Today I learned an interesting concept while working with numbers in Java. When we cast a decimal value to an integer, Java does not round the number—it simply truncates the decimal part. Example: (int) 9.99 = 9 ❗ (Not 10) If we actually want rounding, we should use the Math class: Math.round(9.99) → 10 This is an important detail because many beginners assume casting will round values, but it doesn’t. Understanding this helps avoid logical errors in programs. 💻 Challenge I tried today: Simulate 10 dice rolls using Java’s Math class and random number logic. Example approach: for (int i = 1; i <= 10; i++) { int dice = (int)(Math.random() * 6) + 1; System.out.println("Roll " + i + ": " + dice); } Learning small but powerful concepts every day and building strong Java fundamentals step by step 🚀 #Java #CoreJava #MathClass #TypeCasting #Programming #JavaLearning #100DaysOfCode
Allaka Yamuna lakshmi’s Post
More Relevant Posts
-
Today I explored some fundamental yet powerful concepts in Java that every developer should have a strong grip on: 🔹 Static Methods & VariablesUnderstanding how static members are shared across all objects really changed how I think about memory and efficiency. It’s amazing how a simple static keyword can help track object creation and maintain shared data seamlessly. 🔹 Constructor Overloading & this KeywordThis concept made object initialization much more flexible. Using multiple constructors and the this keyword not only improves code readability but also avoids redundancy. 💡 What I realized:Strong basics are the real game-changer. These concepts might look simple, but they build the foundation for writing clean, scalable, and efficient code. 📌 Consistency in learning > Complexity in topics I’m currently focusing on strengthening my core Java skills and building projects around them. Every small concept learned today contributes to becoming a better developer tomorrow. #Java #Programming #CodingJourney #DeveloperLife #JavaDeveloper #Learning #TechSkills #Coding #StudentDeveloper
To view or add a comment, sign in
-
🚀 DSA in Java – Day 89 ✅ Today, I solved the Minimum Distance to the Target Element problem on LeetCode 💻 🔍 Problem Insight: Given an array, a target element, and a starting index — we need to find the minimum distance between the start index and any occurrence of the target. 🧠 Approach I Used: Traversed the array using a loop Checked where the element equals the target Calculated distance using Math.abs(i - start) Updated the minimum distance using Math.min() ⚡ Key Learning: Sometimes the simplest linear traversal (O(n)) gives the most optimal solution. No need to overcomplicate! 💡 Code Concept: Use a variable to track minimum distance Update it whenever a closer target is found 💬 What I Learned Today: Consistency is more important than complexity. Even simple problems strengthen your fundamentals! 🔥 Day 89 Progress: Strengthened problem-solving skills Improved understanding of distance-based logic Practiced writing clean and optimized Java code 📈 Still learning, still growing… one problem at a time! #LeetCode #DSAinJava #ProblemSolving #Java #CodingJourney #Consistency #SoftwareDeveloper 🚀
To view or add a comment, sign in
-
-
🚀 Day 16/45 – Understanding Abstraction in Java On Day 16 of my Java learning journey, I explored Abstraction, one of the core principles of Object-Oriented Programming. Abstraction focuses on hiding implementation details and showing only the essential functionality to the user. 📚 What I Learned Today Today I learned: ✔ What abstraction is and why it is important ✔ How to use abstract classes in Java ✔ Understanding abstract methods (methods without body) ✔ How abstraction works with inheritance 💻 Practice Work To apply my learning, I implemented: • An animal example using abstract class • A shape example demonstrating abstraction 🎯 Key Takeaway Abstraction helps simplify complex systems by hiding unnecessary details and focusing on what is important. It plays a key role in building clean and scalable applications. Step by step, I am gaining a deeper understanding of OOP concepts. #Java #Programming #LearningInPublic #CodingJourney #SoftwareDevelopment #OOP
To view or add a comment, sign in
-
🚀 DSA Learning Journey | Day 9 | Java Solved “125. Valid Palindrome.” 💡 Key Idea: Used Two Pointers while ignoring non-alphanumeric characters and comparing characters in a case-insensitive way. ⚙ Implementation • Language: Java • Time Complexity: O(n) • Space Complexity: O(1) 📚 Learning how two-pointer technique simplifies string validation problems. #Java #DSA #LeetCode #ProblemSolving #TwoPointers #JavaDeveloper
To view or add a comment, sign in
-
-
🚀 New YouTube Video Alert! I just uploaded a new video where I practice Java loops by building a Multiplication Table Exercise 🧮 In this tutorial, I explain and demonstrate how to use: 🔹 "for" loop 🔹 "while" loop We go step by step to understand how iteration works in Java and how loops can simplify repetitive tasks. 💡 This exercise is perfect for beginners who want to strengthen their logic and improve their programming skills. 📺 Watch the full video here: [https://lnkd.in/dPqCz2h8] Let’s keep learning and building strong programming fundamentals together 💻🔥 #Java #Programming #Loops #Coding #YouTube #SoftwareDevelopment #LearnToCode
multiplication table in java using for and while loop
https://www.youtube.com/
To view or add a comment, sign in
-
🚀 Starting my journey in Java programming! Today I implemented a simple concept with a Program— Factorial of a number. Factorial is widely used in mathematics and programming problems. Through this program, I practiced loops, condition handling, and method creation in Java. 💡 What I learned: • Writing reusable methods • Handling edge cases (like negative numbers) • Taking user input using Scanner • Strengthening my logic-building skills Here’s my implementation: import java.util.*; class FactorialProgram { private static int factorial(int a) { int fact = 1; if (a >= 0) { for (int i = a; i >= 1; i--) { fact = fact * i; } } else { System.out.println("Factorial of negative numbers cannot be determined"); return 0; } return fact; } public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Enter the number: "); int a = sc.nextInt(); System.out.println("\nFactorial of the Number: " + factorial(a)); sc.close(); } } Would love feedback or suggestions to improve this further 🙌, as i am learning please help!! #Java #Programming #CodingJourney #LearningInPublic #BeginnerDeveloper #TechSkills
To view or add a comment, sign in
-
🚀 Day 37 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Two-Pointer Technique 🧩 Problem Solved: Squares of a Sorted Array Problem: Given a sorted array of integers (including negatives), return a new array of the squares of each number, also sorted in non-decreasing order. Approach: Used a two-pointer approach from both ends of the array. Compared squares of elements and filled the result array from the end to maintain sorted order efficiently. Key Learning: ✔️ Handling negative values in sorted arrays ✔️ Using two-pointer technique for optimal solutions ✔️ Avoiding extra sorting to achieve O(n) time complexity If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Arrays #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Day 38 of Learning Java Today, I explored how a class executes inside the JVM (Java Virtual Machine). Understanding this lifecycle really helped me see what happens behind the scenes when we run a Java program. 🔹 Class Loading • The JVM loads the class into memory • It brings the ".class" file into the system 🔹 Linking Phase • Verification → Checks bytecode for errors • Preparation → Allocates memory for static variables (default values like 0) • Resolution → Replaces symbolic references with actual memory references 🔹 Initialization • Static variables get their actual assigned values • Static blocks are executed 🔹 Execution • Methods start running and the program logic is executed 🔹 Destruction • Objects are destroyed and memory is cleaned up by the Garbage Collector Static variables first get default values during preparation, and later their actual values during initialization. Thanks to my mentor Ashim Prem Mahto for the clear explanations and for always clearing my doubts. #Java #JVM #LearningJourney #Programming #SoftwareDevelopment #BackendDevelopment #CodingLife #JavaDeveloper #TechLearning #StudentLife
To view or add a comment, sign in
-
-
Day 12 of Learning Java Today I learned something small in Java that actually plays a big role in programming — Type Casting. At first, I thought it was complicated. But the idea is actually simple. Sometimes in programming, we need to convert one data type into another. For example, converting an `int` into a `double`. That process is called Type Casting. Java mainly has two types of type casting: - Implicit Casting (Widening) This happens automatically when converting a smaller data type into a larger one. Example: `int → double` - Explicit Casting (Narrowing) This is done manually when converting a larger type into a smaller one. Example: `double → int` Simple example: int num = 10; double result = num; // implicit casting double price = 19.99; int rounded = (int) price; // explicit casting What I’m realizing while learning Java is that even small concepts build the foundation of programming logic. Slowly learning. Step by step. #JavaLearning #LearningInPublic #CodingJourney #JavaProgramming #WomenInTech
To view or add a comment, sign in
-
🚀 Mastering Java Through LeetCode 🧠 Day 21 of My DSA Journey 📌 Problem Solved: Q.1657 – Determine if Two Strings Are Close 💡 Problem Insight: At first glance, this problem looks like a simple string comparison… But it actually tests your understanding of patterns, hashing, and transformations. We are allowed to: ✔ Swap characters (change order) ✔ Transform characters (swap frequencies) 🧠 Key Learning: Two strings are "close" if: ✅ They have the same set of characters ✅ Their frequency distribution matches (order doesn’t matter) 👉 That means: Order is irrelevant Only character presence + frequency pattern matters 🔍 Approach I Used: 1️⃣ Checked if lengths are equal 2️⃣ Counted frequency using arrays 3️⃣ Verified both strings have same unique characters 4️⃣ Sorted frequency arrays and compared ⚡ Example: word1 = "cabbba" word2 = "abbccc" ✔ Same characters → {a, b, c} ✔ Frequencies match after sorting → [1,2,3] 👉 Result: true Tech Stack: Java Concepts Covered: Hashing | Arrays | Frequency Count Takeaway: This problem taught me how to: Think beyond direct comparison Focus on data patterns instead of structure Consistency + Practice = Growth #LeetCode #DSA #Java #CodingJourney #100DaysOfCode #ProblemSolving #Developers #SoftwareEngineer #Learning #Growth #CDAC #PlacementPreparation #Tech
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