__omeshwar05__ Profile Banner
Omeshwar Profile
Omeshwar

@__omeshwar05__

Followers
25
Following
25K
Media
8
Statuses
19

India
Joined June 2020
Don't wanna be here? Send us removal request.
@__omeshwar05__
Omeshwar
8 hours
If you found this thread helpful, please like, repost, and drop your feedback β€” it really helps! πŸ‘‡ Follow me for more coding tipsπŸš€ #Java #Coding #DevCommunity #Programmer #TechTwitter #LearnToCode
0
0
1
@__omeshwar05__
Omeshwar
8 hours
When to use Singleton: - Configuration manager - Logging framework - Single database connection pool - When NOT to use it: - When you need multiple instances - When global state causes unwanted coupling - When you’ll need easy testing & mocking
0
0
2
@__omeshwar05__
Omeshwar
8 hours
⚠️ But be careful: Singleton is sometimes considered an anti-pattern. Why? It introduces global state, can make testing harder, and may lead to tight coupling. Use it only when it truly fits the scenario.
1
0
2
@__omeshwar05__
Omeshwar
8 hours
Serialization-Safe Singleton: readResolve() stops deserialization from creating new instance. Pros: Consistent instance Cons: Extra logic needed
1
0
2
@__omeshwar05__
Omeshwar
8 hours
Reflection-Safe Singleton: Throws exception if reflection tries to create 2nd object. Pros: More secure Cons: Still bypassable with tricks
1
0
2
@__omeshwar05__
Omeshwar
8 hours
Enum Singleton: JVM ensures single instance. Handles serialization + reflection. Pros: Most secure Cons: No lazy loading
1
0
2
@__omeshwar05__
Omeshwar
8 hours
Static Inner Class (Bill Pugh): Inner class loads only when needed β†’ lazy + thread-safe. Pros: Cleanest + recommended Cons: None major
1
0
2
@__omeshwar05__
Omeshwar
8 hours
Double-Checked Locking (DCL): Checks twice β†’ avoids locking every time. Pros: Fast + thread-safe Cons: More complex
1
0
2
@__omeshwar05__
Omeshwar
8 hours
Synchronized Method Singleton: Entire method is locked β†’ thread-safe but slow. Pros: Safe Cons: Expensive locking
1
0
2
@__omeshwar05__
Omeshwar
8 hours
Lazy Initialization: Creates instance only on first call. Pros: Lazy, Instance is created only when used. Cons: Breaks in multi-threaded apps
1
0
2
@__omeshwar05__
Omeshwar
8 hours
Eager Initialization: Instance is created immediately when class loads. No lazy loading. Pros: Simple Cons: Wastes memory if unused
1
0
2
@__omeshwar05__
Omeshwar
8 hours
Let’s break down every Singleton pattern in Java with code, pros/cons + a short explanation of how each one works. Perfect for interviews + real-world apps. πŸ‘‡πŸ‘‡ #Java #DesignPatterns
1
0
2
@__omeshwar05__
Omeshwar
19 hours
Learning how things work under the hood makes coding way more fun! πŸ’‘ If you love exploring how core concepts like this actually work β€” ➑️ Follow me for more bite-sized technical content & dev insights! πŸš€
0
0
2
@__omeshwar05__
Omeshwar
19 hours
βš™οΈ Since Java 8, when a single bucket has too many elements, it switches from a LinkedList to a Red-Black Tree for faster lookups (O(log n) instead of O(n)) 🌲 HashMap = elegant mix of array + hashing + tree 🌟 #Java #HashMap #Coding #TechLearning
1
0
2
@__omeshwar05__
Omeshwar
19 hours
To handle collisions: β˜‘οΈ Java compares keys using .equals() β˜‘οΈ If same key β†’ overwrite value β˜‘οΈ If different key β†’ add a new node to the linked list (or tree if many collisions)
1
0
2
@__omeshwar05__
Omeshwar
19 hours
Here’s the magic πŸͺ„ When you call put(key, value) β†’ 1️⃣ Java computes hash = key.hashCode() 2️⃣ It finds the bucket using index = hash % capacity 3️⃣ If that bucket is empty β†’ store directly 4️⃣ If not β†’ check for collisions (keys with same index)
1
0
2
@__omeshwar05__
Omeshwar
19 hours
A HashMap in Java stores key-value pairs β€” but under the hood, it’s powered by: πŸ”Ή Array of buckets πŸ”Ή Linked Lists (or Balanced Trees in some cases) Each key’s position is decided by its hash code, which determines where it goes in memory.
1
0
2
@__omeshwar05__
Omeshwar
19 hours
Just learned how HashMap works internally in Java, and it’s fascinating! πŸ§ πŸ’» Here’s a simple breakdown for anyone who wants to really get it πŸ‘‡
1
0
2
@__omeshwar05__
Omeshwar
3 months
Hey @X πŸ‘‹ I’m looking to #CONNECT with folks who’re into: πŸ‘¨β€πŸ’» Software Development β˜• Java ⚑ JavaScript 🌱 Spring Boot βš›οΈ React 🧩 DSA 🌐 Full Stack Dev πŸ’Ό Freelancing 🎨 Frontend πŸš€ Backend πŸ–₯️ LeetCode Let’s build, learn and grow together πŸ’ͺ #Coding #LearnInPublic #techtwitter
0
0
5