Day 2 - A simple yet tricky aspect of Java Here's a small Java logic that is easy to overlook: System.out.println(5 + 5 + "5"); System.out.println("5" + 5 + 5); At first glance, both statements seem quite similar. However, the outputs are: 👉 105 👉 555 The key difference lies in the order of operations. In the first case, 5 + 5 results in 10, which then concatenates with "5" to produce 105. In the second case, since "5" appears first, everything that follows is treated as a string, resulting in 555. 👉 Once a String is involved, the operation becomes concatenation. This is a straightforward concept, but it's one of those details that can easily be missed if we're not paying attention. #Java #Programming #Coding #JavaDeveloper #Learning #KLU #CSE #ComputerScience
Java String Concatenation Gotcha
More Relevant Posts
-
***Learn Programming with Arrays, Lists, Sets and Maps with Practical Examples*** Session 2: Array Object in Java | Programming with Arrays, Lists, Sets and Maps Series Learn It Easy: https://lnkd.in/dYh-esat #arrays #lists #sets #maps #java #learntocode #seleniumwebdriver #automationtesting #computerprogramming #dezinnia #dezlearn #happylearning
Session 2: Array Object in Java | Programming with Arrays, Lists, Sets and Maps Series
https://www.youtube.com/
To view or add a comment, sign in
-
📚 New article just published on SYUTHD! 🔖 Java 26 vs. Java 25 LTS: Performance Benchmarks and Migration Guide 🏷️ Category: Java Programming 📖 Full article → https://lnkd.in/g-DmkTDW 👉 Follow our page for more tech tutorials: https://lnkd.in/gsJDptPM 💬 Telegram: https://t.me/nisethtechno 👍 Facebook: https://lnkd.in/gsKv3Dyn #JavaProgramming #Tech #Tutorial #Programming #TechBlog #2026
To view or add a comment, sign in
-
Today I Learned: Method Overloading in Java Today I explored one of the most important concepts in Java — Method Overloading. --> Method Overloading allows multiple methods in the same class with the same name but different parameters (type, number, or order). --> Key Points: --> JVM resolves overloaded methods using priority: Exact Match > Widening > Autoboxing > Varargs --> It is an example of Compile-Time Polymorphism --> Improves code readability and flexibility --> Changing only the return type is NOT valid overloading --> We can even overload main() and static methods #Java #Programming #Coding #Developer #100DaysOfCode #LearningJourney #Java #JavaProgramming #JavaDeveloper #SoftwareDevelopment #Programming #Coding #BackendDevelopment #TechLearning #Developers #LearnToCode #ProgrammingCommunity #100DaysOfCode #CodeNewbie #TechCareer #SoftwareEngineer
To view or add a comment, sign in
-
-
90% of your app uses Strings… but do you really know them? Today I spent some time understanding *Strings in Java*… and honestly, it’s deeper than it looks At first, I thought strings are just text we use in programs. But today I learned things like: * Strings are *immutable* (they can’t be changed once created) * Difference between *Heap Memory & String Pool (SCP)* * Why using equals() is important instead of == * And how small things can affect *performance & memory* It’s interesting how such a basic concept plays a huge role in real applications Still learning step by step… but enjoying the process If you’re learning Java too, what topic are you currently on? 👇 #Java #LearningJourney #Coding #Programming #BeginnerDeveloper #SoftwareDevelopment #100DaysOfCode
To view or add a comment, sign in
-
-
While revising Java Collections, I tried to simplify LinkedList in a visual way to make it easier to understand and remember. Here’s what I learned today, LinkedList uses a doubly linked list structure Each element is stored as a node (data + next + previous reference) It does not use continuous memory like arrays There is no fixed capacity, unlike ArrayList - When to use: Use LinkedList when your frequent operations involve insertions and deletions, as they are efficient. - When to avoid: It is not suitable when frequent retrieval (random access) is required, as it takes more time due to traversal. #Java #CollectionsFramework #LinkedList #JavaDeveloper #CodingJourney #LearnInPublic #SoftwareEngineering #Developers #Programming #TechLearning #DSA #BackendDevelopment
To view or add a comment, sign in
-
-
Mastering Java Method Overloading: How the Compiler Thinks Understanding method overloading goes beyond simply writing multiple methods with the same name; it involves grasping how the compiler determines which method to execute. This visual simplifies the resolution process into four key steps: - Method name and parameter count - Exact data type matching - Implicit type promotion when necessary Additionally, it highlights essential concepts such as compile-time polymorphism, early binding, and the occurrence of ambiguity errors. The takeaway? Each overloaded method possesses its own identity, and the compiler adheres to strict rules to select the best match. This is a crucial concept for every Java developer striving to write clean and efficient code! #TapAcademy #Java #Programming #MethodOverloading #Coding #JavaDeveloper #TechLearning #SoftwareDevelopment
To view or add a comment, sign in
-
-
Day 38-What I Learned In a Day (JAVA) Today I focused on number-based problem solving in Java and practiced 10+ problems to strengthen my logic building skills. Topics I covered: 🔹Finding the last digit 🔹Reducing a number to a single digit 🔹Checking Spy Number 🔹Counting digits in a number 🔹Checking Neon Number 🔹Calculating sum & product of digits 🔹Checking Armstrong Number 🔹Identifying Abundant Number 🔹Finding largest & smallest digit 🔹Checking Duck Number 🔹Printing odd digits 🔹Counting, sum, and product of odd digits This practice helped me improve: Looping concepts Conditional logic Number manipulation techniques Consistency in solving problems is helping me build strong fundamentals in Java. #Java #Programming #CodingPractice #ProblemSolving #LearningJourney
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
-
-
Learn Programming with Arrays, Lists, Sets and Maps with Practical Examples Session 1: Concept of Arrays in Java | Programming with Arrays, Lists, Sets and Maps Series Learn It Easy: https://lnkd.in/gad2uaM3 #arrays #programming #automationtesting #sets #maps #lists #java #learntocode #seleniumwebdriver #dezlearn #dezinnia #happylearning
Session 1: Concept of Arrays in Java | Programming with Arrays, Lists, Sets and Maps Series
https://www.youtube.com/
To view or add a comment, sign in
-
Day 34-What I Learned In a Day (JAVA) Today, I focused on pattern programming in Java, especially triangle patterns. I practiced different types of triangle patterns like: 🔹 Increasing triangle 🔹 Decreasing triangle 🔹 Right-aligned triangle 🔹 Reverse triangle Key Learnings: 🔹 Understanding how nested loops control rows and columns 🔹 Learning how to manage spaces and stars 🔹Breaking patterns into simple logic (increase & decrease) 🔹 Improving problem-solving and logical thinking Practiced 👇 #Java #Coding #PatternProgramming #LearningJourney #ProblemSolving
To view or add a comment, sign in
More from this author
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