String vs StringBuilder Both store text. But performance is the difference. String • Immutable • Every change creates a new object StringBuilder • Mutable • Changes happen in the same object Example: String s = "Hello"; s = s + " World"; // new object created StringBuilder sb = new StringBuilder("Hello"); sb.append(" World"); // same object 📌 Use StringBuilder in loops Small optimization. Huge performance impact. #Java #CodingTips #SoftwareDevelopment #Programming
Deep Ghinaiya’s Post
More Relevant Posts
-
Day 13 of #LeetCode75 Complete! 75 Days of Coding Topic: Sliding Window Problem: Maximum Average Subarray I Today, I attempted the Maximum Average Subarray I problem on LeetCode using the Java programming language. The problem required me to find the maximum average value among all possible contiguous subarrays of size 𝑘. 🔍 Approach: I did not use the sliding window technique to find the solution to the problem. Instead, I implemented the optimized solution using the prefix sum technique: I created the prefix sum array to store the cumulative sum. I computed the sum of the subarray using the formula: prefix[i] - prefix[i - 𝑘] and divided the maximum sum by 𝑘. 📚 What I learned: I learned how to use the prefix sum array to store the cumulative sum. I learned how to avoid redundant calculations. I learned the different techniques that could be implemented to solve the sliding window problems. 📌 Key Insight: The prefix sum array is helpful in avoiding redundant calculations. #LeetCode75 #LeetCode #Java #DS #SlidingWindow #ProblemSolving
To view or add a comment, sign in
-
-
Excited to share my recent project where I built a Quiz Game using Java! This application is designed to simulate a real quiz experience in the console, where users answer multiple-choice questions and earn rewards based on their performance. Key Highlights: 10 interactive quiz questions Lifelines: 50-50, Dial a Friend, Quit Real-time scoring system Colored output using ANSI codes (Green / Red / Yellow) Game ends on wrong answer Technologies Used: • Java • Scanner (User Input) • Arrays & Loops • Conditional Logic This project helped me strengthen my understanding of: Core Java concepts Control flow and logic building User interaction handling You can check out the full project report here: Global Quest Technologies #Java #Projects #Programming #BeginnerProjects #SoftwareDevelopment #LearningJourney #Coding
To view or add a comment, sign in
-
✨ DAY-44: 🚧 Struggling with too many setters in Java? You’re not alone! 😅 Ever tried creating a complex object in Java and ended up writing endless setters? Yeah… that moment when your code feels like a pile of scattered LEGO blocks 🧱 That’s exactly where the Builder Pattern comes to the rescue! 💡 Instead of: ❌ Messy object creation ❌ Too many constructors ❌ Confusing parameter order You get: ✅ Clean and readable code ✅ Step-by-step object creation ✅ Better maintainability Just like turning a pile of pieces into a perfect house 🏠 — the Builder Pattern helps you construct objects the right way! 👉 Moral of the story: Don’t fight the complexity, structure it with design patterns. #Java #Programming #DesignPatterns #BuilderPattern #CleanCode #SoftwareDevelopment
To view or add a comment, sign in
-
-
🔥 1. String Coding Questions (Very Frequently Asked) 1. Reverse a string without using StringBuilder. 2. Check if a string is a palindrome. 3. Find the first non-repeating character in a string. 4. Find duplicate characters in a string. 5. Remove duplicate characters from a string. 6. Check if two strings are anagrams. 7. Count vowels and consonants in a string. 8. Find the longest substring without repeating characters. 9. Find the longest palindrome substring. 10. Reverse words in a sentence #java #java8 #frequentlyaskquerions
To view or add a comment, sign in
-
Developers can have their cake and eat it! 🎂 Just like objects, arrays also have an entries() method. But unlike object's entries() method which provides the key and value, array's entries() method provides the index and value. This means you can have the readability and functionality of the for...of loop whilst still easily accessing the index! #develop #object #array #method #function #index #value #key #readability #functionality #easy #access #javascript #typescript #oop #objectorientedprogramming #programming #code https://lnkd.in/dgCJg6Hf
To view or add a comment, sign in
-
-
Day 45-What I Learned In a Day (JAVA) Today I explored some important concepts related to static in Java: 🔹 Static Method Learned how static methods belong to the class and can be called without creating an object. 🔹 Static Initializer (Static Block) Understood how a static block is executed only once when the class is loaded. 🔹 Single-Line Static Initializer Explored how we can initialize static variables in a single line. 🔹 Multi-Line Static Initializer Learned how to use static blocks for complex initialization logic. Practiced 👇 #Java #Programming #LearningJourney #Coding #100DaysOfCode
To view or add a comment, sign in
-
Day 26 - What I Learned In a Day(JAVA) he switch statement is used to select one block of code from multiple options based on the value of an expression. Workflow of Switch Statement 1️⃣ Expression is evaluated The value inside switch(expression) is calculated. 2️⃣ Value is compared with cases The result is compared with each case value. 3️⃣ Matching case executes If a matching case is found, that block of code runs. 4️⃣ break stops the switch break exits the switch statement after executing the matched case. 5️⃣ default runs if no match If none of the cases match, the default block executes. Syntax: switch(expression) { case value1: // statements break; case value2: // statements break; case value3: // statements break; default: // statements } #Java #Programming #JavaSwitch #DecisionMaking #Coding #CaseStatement #BreakStatement #DefaultCase
To view or add a comment, sign in
-
-
What happened when run the code ? @RestController public class TestController { @Autowired private TestService testService; public TestController() { System.out.println(testService.getMessage()); } } Looks correct but throw error ? Answer: NullPointerException Why : spring inject dependencies after constructer execution so testService is null inside constructer #Spring flow is: 1. Object is created (constructor runs first) 2. Then dependency injection happens (@Autowired) #SpringBoot #Java #Backend #CodingInterview #FAANG #Microservices #Programming #Developers
To view or add a comment, sign in
-
-
Day X of #LeetCode75 Complete! 75 Days of Coding Topic: Sliding Window Problem: Maximum Number of Vowels in a Substring of Given Length I solved the Maximum Number of Vowels in a Substring problem on the LeetCode platform using Java. I had to find the maximum number of vowels present in any substring of size k. 🔍 Approach: I applied the sliding window concept to the problem. Count the number of vowels in the initial window size 𝑘. Slide the window one character at a time. Increment the window size by including the next character. Decrement the window size by removing the leftmost character. Maintain the maximum count during the process. 📚 What I learned: Efficient usage of the sliding window concept for fixed window size. Avoiding redundant computation using the sliding window. Efficient usage of character checking using the vowel set. 📌 Key Insight: Normally, checking all substrings individually would take O(n*m) time. But using the sliding window concept, we can achieve O(n) time complexity. #LeetCode75 #CodingChallenge #Java #DSA #SlidingWindow #ProblemSolving
To view or add a comment, sign in
-
-
✨ DAY-43: 🚀 Understanding Factory Pattern in Java – Made Fun! Ever wondered how objects are created behind the scenes without exposing the creation logic? 🤔 This meme perfectly explains the Factory Design Pattern in Java! 🏭 Instead of directly creating objects using new, we delegate the responsibility to a factory method like createVehicle(type). Based on the input, it decides whether to create a 🚗 Car, 🏍️ Bike, or 🚚 Truck. 💡 Why use Factory Pattern? ✔️ Promotes loose coupling ✔️ Enhances code flexibility ✔️ Makes code easier to maintain and scale 👉 In simple terms: “Don’t create objects directly, let the factory handle it!” This visual makes it clear — you just request, and the factory delivers the right object! #Java #DesignPatterns #FactoryPattern #Programming #SoftwareDevelopment #CodingMemes #CleanCode
To view or add a comment, sign in
-
More from this author
-
How AI-Driven Development Tools Are Transforming Software Engineering in 2026
Deep Ghinaiya 10h -
🧠 The Most Important Skill for Developers in 2026: Problem Solving Over Programming
Deep Ghinaiya 3w -
Why LinkedIn Recommendations Still Matter in 2026 (And How to Write One That Actually Helps)
Deep Ghinaiya 2mo
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