Java basic Interview Questions solved with Advance Java Q1. Reverse a String ? //Reverse the String String reverseString = "Java Programming"; System.out.println(new StringBuilder(reverseString).reverse()); Q2. Find Duplicate Characters --> Input : “automation” --> Output: “a-2 t-2 o-2" //Find duplicate Character String duplicate = "automation"; getMapForOccurance(duplicate).entrySet().stream().filter(e -> e.getValue() > 1) .forEach(e -> System.out.println(e.getKey() + "-" + e.getValue())); public static Map < Character, Integer > getMapForOccurance(String abc) { Map < Character, Integer > map = new HashMap < Character, Integer > (); for (char c: abc.toCharArray()) { map.put(c, map.getOrDefault(c, 0) + 1); } return map; } Q3. Count Occurrence of Each Character Input : “test” Output : “ t=2, e=1, s=1” // Count occurrence of Each Character String occurrence = "test"; getMapForOccurance(occurrence).forEach((key, value) -> { System.out.println(key + "-" + value); }); Q4: Palindrome Check < Verify with enter list of numbers > “madam” -> true “Hello” -> false //Palindrom check Scanner sc = new Scanner(System.in); boolean flag = true; List < String > palindrom = new ArrayList < String > (); System.out.println("Enter all the strings to verify Palindrom./n type \"last\" for end the input"); while (flag) { String input = sc.nextLine(); if (input.equalsIgnoreCase("last")) { break; } palindrom.add(input); } palindrom.forEach((pal) -> { if (pal.equals(new StringBuilder(pal).reverse().toString())) { System.out.println(pal + " is Palindrom"); } }); Q5. Find Largest & Smallest in Array // Find largest & Smallest Array int[] values={5,2,9,1}; System.out.println("Largest Number :"+ Arrays.stream(values).max().getAsInt()); System.out.println("Smallest Number :"+ Arrays.stream(values).min().getAsInt()); Q6. Find Largest & Smallest in Collection // Find largest & Smallest Collections List<Integer> values=List.of(5,2,9,1); System.out.println("Largest Number :"+ Collections.max(values)); System.out.println("Smallest Number :"+ Collections.min(values)); Q7. Remove Duplicates from Array //Remove Duplicates from ArrayList int[] input = {1,2,2,3,4,4}; // Output : [1,2,3,4] Set<Integer> set= Arrays.stream(input).boxed() .collect(Collectors.toSet()); System.out.println(set); #AdvanceJava #Java #JavaInterviewQuestioins #QA #AutomationTesting
Java Interview Questions and Solutions
More Relevant Posts
-
Real Java interviews are not about syntax — they are about how you handle production issues. 1. Your application throws OutOfMemoryError after running for a few hours. How will you identify and fix the root cause? 2. You start getting StackOverflowError in production. What could cause it and how will you debug it? 3. Your application shows memory growth over time. How will you detect and fix memory leaks? 4. Multiple threads are updating shared data causing inconsistent results. How will you handle concurrency? 5. Your application faces deadlock between threads. How will you detect and resolve it? 6. You observe high CPU usage but low request throughput. How will you debug it? 7. A thread pool gets exhausted under load. How will you fix and tune it? 8. Your application throws ConcurrentModificationException. How will you resolve it? 9. You see NullPointerException in production but not locally. How will you debug it? 10. Your application becomes slow due to excessive object creation. How will you optimize it? 11. You get ClassNotFoundException or NoClassDefFoundError in production. What could be the issue? 12. A scheduled task runs multiple times unexpectedly. How will you fix it? 13. Your application hangs due to blocked threads. How will you identify the issue? 14. You face race conditions in a critical section. How will you prevent them? 15. Your application throws InterruptedException frequently. How will you handle thread interruptions properly? 16. You see high garbage collection pauses affecting performance. How will you optimize GC? 17. Your application fails due to improper synchronization. How will you fix thread safety? 18. A future or async task never completes. How will you debug it? 19. Your application throws IllegalStateException due to incorrect state handling. How will you fix it? 20. You observe thread starvation in your application. How will you resolve it? 21. A service crashes due to unhandled exceptions. How will you design proper exception handling? 22. Your application shows inconsistent results due to caching issues. How will you fix it? 23. You face issues with serialization/deserialization in Java. How will you debug it? 24. A critical process fails silently without logs. How will you improve observability? 25. Your application behaves differently in production vs local environment. How will you approach debugging? If you can confidently solve these, you are thinking like a production-level Java developer. For detailed Questions and answers and real-world explanations, comment your experience below.
To view or add a comment, sign in
-
💡 Functional Interfaces in Java — Beyond the Basics If you think Functional Interfaces are just about Lambda expressions, you're only scratching the surface. Let’s go deeper 👇 🔹 Recap: What is a Functional Interface? An interface with exactly one abstract method, annotated optionally with "@FunctionalInterface" for clarity and compile-time safety. --- 🔹 Key Characteristics ✔ Can have multiple default and static methods ✔ Enables functional programming style in Java ✔ Works seamlessly with lambda expressions and method references --- 🔹 Custom Functional Interface Example @FunctionalInterface interface Calculator { int operate(int a, int b); } Usage: Calculator add = (a, b) -> a + b; System.out.println(add.operate(5, 3)); // 8 --- 🔹 Lambda vs Method Reference Lambda: (a, b) -> a + b Method Reference: Integer::sum 👉 Cleaner and more reusable when method already exists. --- 🔹 Where are Functional Interfaces Used? 🔥 1. Streams API list.stream() .filter(x -> x > 10) // Predicate .map(x -> x * 2) // Function .forEach(System.out::println); // Consumer 🔥 2. Multithreading new Thread(() -> System.out.println("Running thread")).start(); 🔥 3. Event Handling & Callbacks Used heavily in asynchronous and reactive programming. --- 🔹 Types of Functional Interfaces (Deep View) ✨ Predicate<T> → Boolean conditions Used for filtering data ✨ Function<T, R> → Transformation Convert one form of data to another ✨ Consumer<T> → Performs action Logging, printing, updating ✨ Supplier<T> → Generates data Lazy loading, object creation ✨ BiFunction / BiPredicate → Work with 2 inputs --- 🔹 Why Companies Care? (Interview Insight) ✔ Reduces boilerplate code ✔ Encourages clean architecture ✔ Essential for Spring Boot & Microservices ✔ Frequently used in real-world production code --- 🔹 Common Mistakes to Avoid ❌ Adding more than one abstract method ❌ Ignoring built-in functional interfaces ❌ Overusing lambdas (readability matters!) --- 🔹 Pro Tip for Freshers 🚀 When solving DSA or backend problems, try rewriting logic using: 👉 Lambda expressions 👉 Streams 👉 Built-in functional interfaces This shows modern Java proficiency in interviews. --- 💬 Final Thought: Functional Interfaces are not just a feature—they represent a shift in how Java developers think and write code. Master them, and your code becomes shorter, smarter, and more powerful ⚡ #Java #FunctionalProgramming #Java8 #BackendDeveloper #CodingJourney #SoftwareEngineering #InterviewPrep
To view or add a comment, sign in
-
💥 𝐉𝐚𝐯𝐚 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐐𝐮𝐞𝐬𝐭𝐢𝐨𝐧 𝐘𝐨𝐮 𝐒𝐡𝐨𝐮𝐥𝐝 𝐊𝐧𝐨𝐰 𝐂𝐥𝐞𝐚𝐫𝐥𝐲! 👉 What is Object Cloning and how do you achieve it in Java? 💡 1. What is Object Cloning? Object Cloning is the process of creating an exact copy of an existing object. 👉 Instead of creating a new object manually, cloning allows you to duplicate the object with the same values . ⚙️ 2. How to Achieve Cloning in Java? Java provides: 👉 clone() method (from Object class) But to use it: ✔️ Class must implement Cloneable interface ✔️ Override clone() method . 🔧 Example: 𝒄𝒍𝒂𝒔𝒔 𝑺𝒕𝒖𝒅𝒆𝒏𝒕 𝒊𝒎𝒑𝒍𝒆𝒎𝒆𝒏𝒕𝒔 𝑪𝒍𝒐𝒏𝒆𝒂𝒃𝒍𝒆 { 𝒊𝒏𝒕 𝒊𝒅; 𝑺𝒕𝒓𝒊𝒏𝒈 𝒏𝒂𝒎𝒆; 𝑺𝒕𝒖𝒅𝒆𝒏𝒕(𝒊𝒏𝒕 𝒊𝒅, 𝑺𝒕𝒓𝒊𝒏𝒈 𝒏𝒂𝒎𝒆) { 𝒕𝒉𝒊𝒔.𝒊𝒅 = 𝒊𝒅; 𝒕𝒉𝒊𝒔.𝒏𝒂𝒎𝒆 = 𝒏𝒂𝒎𝒆; } 𝒑𝒖𝒃𝒍𝒊𝒄 𝑶𝒃𝒋𝒆𝒄𝒕 𝒄𝒍𝒐𝒏𝒆() 𝒕𝒉𝒓𝒐𝒘𝒔 𝑪𝒍𝒐𝒏𝒆𝑵𝒐𝒕𝑺𝒖𝒑𝒑𝒐𝒓𝒕𝒆𝒅𝑬𝒙𝒄𝒆𝒑𝒕𝒊𝒐𝒏 { 𝒓𝒆𝒕𝒖𝒓𝒏 𝒔𝒖𝒑𝒆𝒓.𝒄𝒍𝒐𝒏𝒆(); } } 𝒑𝒖𝒃𝒍𝒊𝒄 𝒄𝒍𝒂𝒔𝒔 𝑴𝒂𝒊𝒏 { 𝒑𝒖𝒃𝒍𝒊𝒄 𝒔𝒕𝒂𝒕𝒊𝒄 𝒗𝒐𝒊𝒅 𝒎𝒂𝒊𝒏(𝑺𝒕𝒓𝒊𝒏𝒈[] 𝒂𝒓𝒈𝒔) 𝒕𝒉𝒓𝒐𝒘𝒔 𝑬𝒙𝒄𝒆𝒑𝒕𝒊𝒐𝒏 { 𝑺𝒕𝒖𝒅𝒆𝒏𝒕 𝒔1 = 𝒏𝒆𝒘 𝑺𝒕𝒖𝒅𝒆𝒏𝒕(1, "𝑱𝒐𝒉𝒏"); 𝑺𝒕𝒖𝒅𝒆𝒏𝒕 𝒔2 = (𝑺𝒕𝒖𝒅𝒆𝒏𝒕) 𝒔1.𝒄𝒍𝒐𝒏𝒆(); 𝑺𝒚𝒔𝒕𝒆𝒎.𝒐𝒖𝒕.𝒑𝒓𝒊𝒏𝒕𝒍𝒏(𝒔1.𝒏𝒂𝒎𝒆); 𝑺𝒚𝒔𝒕𝒆𝒎.𝒐𝒖𝒕.𝒑𝒓𝒊𝒏𝒕𝒍𝒏(𝒔2.𝒏𝒂𝒎𝒆); } } . 🔍 3. Types of Cloning (Very Important) 🔹 Shallow Copy ✔️ Copies object ❌ References are shared 👉 Changes in one may affect another . 🔹 Deep Copy ✔️ Copies object + nested objects ✔️ Completely independent 👉 Safer for real-world applications . ⚠️ 4. Important Points ✔️ Cloneable is a marker interface ✔️ If not implemented → CloneNotSupportedException ✔️ clone() gives field-to-field copy ✔️ Default cloning = shallow copy . 🎯 5. Alternative to Cloning (Best Practice) 👉 Instead of clone(): ✔️ Copy constructor ✔️ Factory methods 💡 Many developers avoid clone due to complexity . 🔥 6. Why This Question is Important? ✔️ Frequently asked in Core Java interviews ✔️ Tests understanding of memory & object behavior ✔️ Important for real-world object handling . 🎯 Perfect Interview Answer: “Object cloning in Java is the process of creating a copy of an object using the clone() method. The class must implement Cloneable interface. By default, cloning creates a shallow copy, and deep copy must be handled manually.” . 💬 Let’s discuss: Do you prefer using clone() or copy constructors in real projects? 👇 Comment your answer . #Java #CoreJava #JavaInterview #OOP #ObjectOrientedProgramming #Programming #Developers #Coding #SoftwareDevelopment #JavaDeveloper #TechLearning #InterviewPreparation #CodingInterview #DeveloperLife
To view or add a comment, sign in
-
-
Stop writing Java Switch statements like it’s 2004! If you are still writing switch statements with break; at the end of every line, you are living in the past! Java has transformed the humble switch from a clunky branching tool into a powerful, functional expression. Here is the evolution of how we control logic in Java: 1️⃣ The "Classic" Era (Java 1.0 - 6) * Syntax: case X: ... break; * Limitation: Only primitives (int, char) and Enums. * The Risk: "Fall-through" bugs. Forget one break and your logic cascades into chaos. 2️⃣ The "Modern Expression" (Java 14) Java 14 turned the Switch into an Expression. It can now return a value! * Arrow Syntax (->): No more break. It’s cleaner and safer. * Assignment: var result = switch(val) { ... }; * Yield: Use yield to return values from complex multi-line blocks. 3️⃣ The "Pattern Matching" Powerhouse (Java 21) This is the game changer. Switch is no longer just for values; it’s for Types. * Case Patterns: Switch directly on an Object. * Automatic Casting: No more instanceof followed by manual casting. * Guarded Patterns: Use the when keyword to add logic filters directly into the case. * Null Safety: Explicitly handle case null without crashing. Sample : /** * SCENARIO: Processing a result object that could be * a String, an Integer, or a custom Status record. */ // 🛑 THE OLD WAY (Java 8) - Verbose and manual public String handleResultOld(Object result) { if (result == null) { return "Unknown"; } if (result instanceof String) { String s = (String) result; // Manual casting return "Message: " + s; } else if (result instanceof Integer) { Integer i = (Integer) result; return "Code: " + i; } return "Unsupported"; } // ✅ THE MODERN WAY (Java 21) - Concise and Type-Safe public String handleResultModern(Object result) { return switch (result) { case null -> "Unknown"; case String s when s.isBlank() -> "Empty Message"; case String s -> "Message: " + s; // Automatic casting case Integer i -> "Code: " + i; default -> "Unsupported"; }; } #Java21 #ModernJava #BackendDevelopment #Coding #TechCommunity #Developers #LearningToCode
To view or add a comment, sign in
-
Spring Boot Interview Series — Java — Post 21 Java has two types of data - primitives and non-primitives. Understanding the difference tells you how data is stored, accessed, and managed in memory. 8 Primitive Types byte, short, int, long, float, double, char, boolean Stored directly on the Stack. Fixed size. No methods. Cannot be null. Faster than objects - direct value access, no object overhead. Non-Primitives - Reference Types -> String - immutable. Stored in the String Pool on the Heap. Has methods. Can be null. -> Arrays - fixed size. Stored on the Heap. Can hold both primitives and reference types. -> Classes - objects created with new. Stored on the Heap. Can be null. -> Interfaces - reference types. Cannot be instantiated directly. Define a contract. Stack vs Heap -> Stack - stores primitive values and object references. Thread-specific, LIFO, fast. Automatically cleared when the method exits. int x = 10; // stored directly on stack -> Heap - stores all objects and arrays. Shared across threads. Managed by Garbage Collector. Slower than stack. BankAccount acc = new BankAccount(); // object on heap, reference on stack Wrapper Classes + Autoboxing Every primitive has a wrapper class- int → Integer, double → Double, boolean → Boolean, char → Character. Autoboxing - automatic conversion from primitive to wrapper. Unboxing - automatic conversion from wrapper to primitive. int x = 5; Integer y = x; // autoboxing int z = y; // unboxing Interview trap - Integer cache: Integer caches values from -128 to 127. Outside this range, == returns false because new objects are created. Integer.valueOf(127)
To view or add a comment, sign in
-
-
Java Interview Topic: equals() and hashCode() In Java, equals() and hashCode() are two very important methods, especially when working with collections like HashMap, HashSet, and Hashtable. By default, equals() checks whether two object references point to the same memory location. But in real-world applications, we usually want to compare objects based on their data. Example: class Employee { int id; String name; } Now imagine two Employee objects: Employee e1 = new Employee(1, "Ram"); Employee e2 = new Employee(1, "Ram"); Logically, both employees are the same because their id and name are the same. But without overriding equals(), Java may treat them as different objects. That is why we override equals(). But why hashCode()? Because hash-based collections like HashMap and HashSet first use hashCode() to decide where to store or find the object. Important rule: If two objects are equal according to equals(), they must have the same hashCode(). But if two objects have the same hashCode(), they are not always equal. So whenever you override equals(), you should also override hashCode(). Simple formula to remember: equals() → checks object equality hashCode() → helps in faster searching inside hash-based collections This is one of the most commonly asked Java interview topics, but it is also very important in real-world development. Understanding this concept helps you avoid bugs in HashMap, HashSet, and object comparison logic. #Java #CoreJava #JavaDeveloper #BackendDevelopment #SpringBoot #Programming #SoftwareDevelopment #Coding #InterviewPreparation #HashMap #ObjectOrientedProgramming #100DaysOfCode
To view or add a comment, sign in
-
-
Java Strings — Part 2: String Constant Pool (SCP) Deep Dive 🔥 If you don’t understand String Pool, you’ll struggle with at least 30% of Java interview questions on Strings. Let’s break it down clearly 👇 ⸻ 🔹 What is String Constant Pool (SCP)? 👉 A special memory area inside the Heap where Java stores unique String literals String s1 = "abc"; String s2 = "abc"; 💡 Both s1 and s2 point to the same object in the String Pool ⸻ 🔹 Why String Pool exists? ✔ Memory optimization (no duplicate objects) ✔ Faster comparisons using references ✔ Improves performance ⸻ 🔹 Object Creation — Most Important Concept 🔥 ✅ Case 1: Using Literal String s1 = "hello"; String s2 = "hello"; 👉 Only 1 object created in SCP ⸻ ✅ Case 2: Using new keyword String s1 = new String("hello"); 👉 2 objects created: 1. One in SCP (“hello”) 2. One in Heap (new object) ⸻ ✅ Case 3: Combination String s1 = "hello"; String s2 = new String("hello"); 👉 Total objects: * 1 in SCP * 1 in Heap ⸻ 🔹 == vs .equals() (Interview Trap ⚠️) String s1 = "abc"; String s2 = "abc"; System.out.println(s1 == s2); // true String s3 = new String("abc"); System.out.println(s1 == s3); // false ✔ == → compares references ✔ .equals() → compares values ⸻ 🔹 intern() Method (Advanced 🔥) String s1 = new String("hello"); String s2 = s1.intern(); 👉 intern() forces the String into SCP 💡 Now s2 will point to SCP reference ⸻ 🔹 Tricky Interview Questions ⚠️ Q1: How many objects? String s = new String("xyz"); 👉 Answer: 2 objects ⸻ ⚠️ Q2: How many objects? String s1 = "a" + "b"; 👉 Answer: 1 object (compile-time optimization) ⸻ ⚠️ Q3: How many objects? String s1 = "a"; String s2 = s1 + "b"; 👉 Answer: 2 objects (runtime concatenation) ⸻ 🔹 Compile-Time vs Runtime Concatenation ✔ Compile-time → goes to SCP ✔ Runtime → creates new object in Heap ⸻ 🔥 Final Takeaway ✔ String Pool avoids duplicate objects ✔ Literals use SCP, new creates extra object ✔ == vs .equals() is a must-know ✔ intern() is an advanced optimization tool #Java #SDET #AutomationTesting #JavaInterview #StringPool #Programming #TechLearning :::
To view or add a comment, sign in
-
⏳Day 32 – 1 Minute Java Clarity – Comparable vs Comparator** Both sort. But who controls the sorting logic? ⚡ 📌 Core Difference: Comparable = object sorts itself (natural order). Comparator = external class defines custom sort logic. 📌 Code Comparison: import java.util.*; // Comparable – natural order (by age) class Student implements Comparable<Student> { String name; int age; Student(String name, int age) { this.name = name; this.age = age; } public int compareTo(Student other) { return this.age - other.age; // sort by age ascending } public String toString() { return name + "(" + age + ")"; } } // Comparator – custom order (by name) class NameComparator implements Comparator<Student> { public int compare(Student a, Student b) { return a.name.compareTo(b.name); // sort by name } } public class SortingDemo { public static void main(String[] args) { List<Student> students = Arrays.asList( new Student("Charlie", 22), new Student("Alice", 20), new Student("Bob", 21) ); Collections.sort(students); // Comparable → by age System.out.println(students); // [Alice(20), Bob(21), Charlie(22)] students.sort(new NameComparator()); // Comparator → by name System.out.println(students); // [Alice(20), Bob(21), Charlie(22)] // Java 8 Lambda Comparator students.sort((a, b) -> b.age - a.age); // sort by age descending System.out.println(students); } } 📌 Head-to-Head Comparison: | Feature | Comparable | Comparator | |---|---|---| | Package | java.lang | java.util | | Method | compareTo() | compare() | | Sort logic location | Inside the class | Outside the class | | Multiple sort orders | ❌ One only | ✅ Multiple | | Modifies class | ✅ Yes | ❌ No | 💡 Real-time Example: 👨🎓 Student Leaderboard : Comparable → Default sort by marks (fixed rule) Comparator → Sort by name, age, or rank depending on view ⚠️ Interview Trap: Can you use both Comparable and Comparator together? 👉 Yes! Comparable sets the default order. 👉 Comparator overrides it when passed explicitly. 📌 Pro Tip: // Java 8 Comparator chaining: students.sort( Comparator.comparing((Student s) -> s.age) .thenComparing(s -> s.name) ); // sort by age, then by name ✅ 💡 Quick Summary: ✔ Comparable → natural sort, modifies the class ✔ Comparator → custom sort, external, flexible ✔ Comparable uses compareTo(), Comparator uses compare() ✔ Use Comparator when you can't modify the class ✔ Java 8+ → prefer lambda Comparators ✅ 🔹 Next Topic → Java 8 Streams Introduction Did you know you can chain multiple Comparators in Java 8 with thenComparing()? Drop 🔥 if this was new to you! #Java #Comparable #Comparator #Sorting #JavaCollections #CoreJava #1MinuteJavaClarity #JavaDeveloper #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Java Streams Interview Gem: Find Duplicate Numbers in a List Working with collections is common, but identifying duplicates efficiently is a must-have skill for any Java developer 💡 Here’s how you can find duplicate numbers using Java Streams 👇 🔹 Approach: We use a Set to track elements and filter duplicates while streaming the list. 🔹 Code: import java.util.*; import java.util.stream.*; public class FindDuplicates { public static void main(String[] args) { List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 2, 5, 6, 3, 7, 1); Set<Integer> seen = new HashSet<>(); Set<Integer> duplicates = numbers.stream() .filter(n -> !seen.add(n)) .collect(Collectors.toSet()); System.out.println("Duplicate Numbers: " + duplicates); } } 🔹 Output: Duplicate Numbers: [1, 2, 3] 🔹 How it works? ✔ seen.add(n) returns false if the element is already present ✔ We filter those elements → duplicates ✔ Collect them into a Set to avoid repeated duplicates 💥 Alternative (Using Grouping): 🔥 Mastering Streams = Cleaner + More Functional Code #Java #JavaStreams #CodingInterview #Developers #Programming #Tech #100DaysOfCode
To view or add a comment, sign in
-
One Java method. Zero extra objects. Massive memory saving. intern() is the most underused String method in Java. Here's how it saved memory in our fintech system. 👇 In Risk Shield, we process thousands of transaction records per second. Each record carries repeated Strings — currency codes, status flags, country codes like "INR", "USD", "ACTIVE", "PENDING". Without intern() — each was a separate heap object. With intern() — one shared object in the String Pool. Memory dropped by 30% overnight. Here's everything you need to know about intern(): → What it does Moves a String from heap into the String Pool If same value already exists in pool — returns that reference No duplicate String objects in memory → Without intern() String s1 = new String("INR") → new heap object String s2 = new String("INR") → another new heap object s1 == s2 → FALSE (two different references) 2 objects consuming memory for the same value → With intern() String s1 = new String("INR").intern() → goes to pool String s2 = new String("INR").intern() → reuses pool reference s1 == s2 → TRUE (same reference) 1 object shared across entire JVM → Where intern() actually saves memory Repeated currency codes — "INR" "USD" "EUR" Status flags — "ACTIVE" "PENDING" "FAILED" Country codes — "IN" "US" "UK" Any high-frequency repeated String value → When NOT to use intern() Unique Strings like customer IDs or UUIDs intern() on unique values = String Pool bloat More objects in pool = more GC pressure → Performance note intern() has a small CPU cost (pool lookup) Worth it only when same String repeats 100s of times Profile first — optimize second → Java 7+ advantage String Pool is now in Heap (not PermGen) Interned Strings are now garbage collectible Safe to use intern() without OOM risk in older Java versions My rule in fintech systems: If a String value repeats more than 50 times per second → intern() it. Have you ever used intern() in production? What was the use case? Drop it below 👇 Save this — you'll need it in your next Java interview. 🔖 #Java #CoreJava #JavaDeveloper #BackendEngineering #Fintech
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