Lovepreet S (Java Experts) ☁️

2.1K posts

Lovepreet S (Java Experts) ☁️ banner
Lovepreet S (Java Experts) ☁️

Lovepreet S (Java Experts) ☁️

@java_experts

★ Sr Backend Developer | 9+ years Experience ★ Sharing my experience via tweets & threads ★ Explains complex concepts

Punjab Sumali Mayıs 2022
126 Sinusundan1.5K Mga Tagasunod
Lovepreet S (Java Experts) ☁️
In Action Integer num1 = 50; Integer num2 = 50; System.out.println(num1 == num2); // true (pooled!) Integer num3 = 150; Integer num4 = 150; System.out.println(num3 == num4); // false (not pooled!)
Svenska
0
0
0
26
Lovepreet S (Java Experts) ☁️
The Tricky Part: == vs .equals() This is where == gets tricky! == checks if two references point to the exact same object. For numbers in the pool, they often do. Outside the pool, even if values are identical, they're separate objects. Always use .equals() for value comparison
English
1
0
0
34
Lovepreet S (Java Experts) ☁️
Key Takeaways: Java's String Pool reuses literals. new String() always creates new objects. intern() forces pooling. == vs .equals() is crucial for comparison
English
0
0
0
30
Lovepreet S (Java Experts) ☁️
Classic Gotcha: `==` vs `.equals()` Comparing user input (often dynamically created Strings) with constant literals using == will likely fail! ❌ Always use .equals() for content comparison. Remember: == for reference, .equals() for value.
English
1
0
0
34
Lovepreet S (Java Experts) ☁️
Ever wonder why "hello" == "hello" is true, but new String("hello") == new String("hello") is false? Let's unravel this 👇 The String Pool
English
1
0
0
40
Lovepreet S (Java Experts) ☁️
Q: How do you share variable in thread life cycle? A: Java ThreadLocal class allows the storage of data that is specific to each thread separately. It is often used to implement thread-specific context or to avoid synchronisation for thread-local data
Lovepreet S (Java Experts) ☁️ tweet media
English
0
0
4
1.1K
Vikas Rajput
Vikas Rajput@vikasrajputin·
Find a good senior in your workplace, spent time with them, ask your technical doubts, discuss concepts with them, literally observe how they're doing what they're doing. You'll grow 10x just by observing and following a Good mentor. This is what I literally did to grow in my early days.
English
1
1
30
3.1K
Danny Thompson
Danny Thompson@DThompsonDev·
What advice would you give to someone who is about to start their first job in tech working at a company?
English
102
35
337
112.1K
Shubh
Shubh@Shubh28659122·
@java_experts Well, threads are such concepts which depend on core.
English
1
0
0
32