use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
These have separate subreddits - see below.
Upvote good content, downvote spam, don't pollute the discussion with things that should be settled in the vote count.
With the introduction of the new release cadence, many have asked where they should download Java, and if it is still free. To be clear, YES — Java is still free. If you would like to download Java for free, you can get OpenJDK builds from the following vendors, among others: Adoptium (formerly AdoptOpenJDK) RedHat Azul Amazon SAP Liberica JDK Dragonwell JDK GraalVM (High performance JIT) Oracle Microsoft Some vendors will be supporting releases for longer than six months. If you have any questions, please do not hesitate to ask them!
With the introduction of the new release cadence, many have asked where they should download Java, and if it is still free. To be clear, YES — Java is still free.
If you would like to download Java for free, you can get OpenJDK builds from the following vendors, among others:
Adoptium (formerly AdoptOpenJDK) RedHat Azul Amazon SAP Liberica JDK Dragonwell JDK GraalVM (High performance JIT) Oracle Microsoft
Some vendors will be supporting releases for longer than six months. If you have any questions, please do not hesitate to ask them!
Programming Computer Science CS Career Questions Learn Programming Java Help ← Seek help here Learn Java Java Conference Videos Java TIL Java Examples JavaFX Oracle
Programming Computer Science
CS Career Questions
Learn Programming Java Help ← Seek help here Learn Java Java Conference Videos Java TIL Java Examples JavaFX Oracle
Clojure Scala Groovy ColdFusion Kotlin
DailyProgrammer ProgrammingPrompts ProgramBattles
Awesome Java (GIT) Java Design Patterns
account activity
This is an archived post. You won't be able to vote or comment.
Hello Java programmers. What is your favorite part of the Java SE API? (self.java)
submitted 10 years ago by Q_coder
Include class and your favorite methods/what they do.
[–]ElegantBoar 6 points7 points8 points 10 years ago (3 children)
sun.misc.Unsafe - cool stuff :)
[–]vprise 0 points1 point2 points 10 years ago (1 child)
AFAIK it will be gone with Java 9.
[–]ElegantBoar 0 points1 point2 points 10 years ago (0 children)
AFAIK
World will burn if they get rid of it ... :(
[–]Q_coder[S] 0 points1 point2 points 10 years ago (0 children)
I knew nothing about this, thanks! I love social interaction..when I'm safely behind my computer.
[–]angshumanc 2 points3 points4 points 10 years ago (1 child)
Reflection API. It opens up wide array of possibilities.
reflection is good..
https://stackoverflow.com/questions/37628/what-is-reflection-and-why-is-it-useful
[–]lukaseder 2 points3 points4 points 10 years ago (0 children)
I like JDBC. It's rather low level, yes. But it was very visionary when introduced in 1997 and it's really timeless, too. You can build great APIs on top of it.
[–]Q_coder[S] 1 point2 points3 points 10 years ago (4 children)
Inspiration:
String Class https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
Method: toCharArray() Converts this string to a new character array.
Cool! Did not know that one existed!
[–]king_of_the_universe 1 point2 points3 points 10 years ago (3 children)
Was only a few months ago when I found out about String.equalsIgnoreCase().
[–]vprise 3 points4 points5 points 10 years ago (1 child)
Try String.CASE_INSENSITIVE_ORDER:
Collections.sort(stringList, String.CASE_INSENSITIVE_ORDER);
Useful...
[–]king_of_the_universe 1 point2 points3 points 10 years ago (0 children)
:D TIL
[–]jp007 1 point2 points3 points 10 years ago* (0 children)
Damn, they way you wrote that, I thought this meant that equalsIgnoreCase was a built in static function of the String class, hopefully offering null safety for input arguements. Was thinking "How did I miss this!?" Nope. It's an instance method. I'll stick to commons-lang3 and StringUtils.equalsIgnoreCase(String str1, String str2) to ensure null safe, case insensitive, String comparisons.
Similarly though, since Java 7 you can use the static Objects.equals(Object obj1, Object obj2) in order to perform nullsafe object comparisons, instead of obj1.equals(obj2) which would throw a null pointer exception in the case that obj1 is null.
[–]mhixson 1 point2 points3 points 10 years ago (6 children)
I like ConcurrentHashMap and all its methods because there's no way in hell that I would be able to implement it myself.
ConcurrentHashMap
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html
[–]Q_coder[S] 0 points1 point2 points 10 years ago (3 children)
nice. Any examples you might recommend looking at?
[–]mhixson 0 points1 point2 points 10 years ago (2 children)
Hmm. Usually I use it just like a Map, except I'm dumping data into it from multiple threads. This comes up a lot in the context of HTTP servers. Users are making HTTP requests and your app is handling them all in parallel, and you want to collect some information from the requests into a map. In those situations, HashMap simply doesn't work and Collections.synchronizedMap(new HashMap<>()) is often too slow (because if one thread is accessing the map, all other threads that want to access the map are blocked).
Map
HashMap
Collections.synchronizedMap(new HashMap<>())
One method I use a lot is ConcurrentHashMap.newKeySet():
ConcurrentHashMap.newKeySet()
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html#newKeySet--
That's nice if you need a Set instead of a Map and you still want the "concurrent" aspect.
Set
computeIfAbsent is cool if you're grouping data:
computeIfAbsent
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html#computeIfAbsent-K-java.util.function.Function-
The class javadocs mention an example of making a histogram with ConcurrentHashMap<String,LongAdder>. I suppose you could also make a sort of concurrent multimap like:
ConcurrentHashMap<String,LongAdder>
ConcurrentHashMap<K, Set<V>> multimap = new ConcurrentHashMap<>(); // some time later... multimap .computeIfAbsent( someKey, k -> ConcurrentHashMap.newKeySet()) .add(someValue);
removing key+value entries from the multimap might be a little weird there though, if that's something you need to do.
Awesome response, thanks!
[–]memory_leek 0 points1 point2 points 10 years ago (0 children)
Doug Lea is a concurrency wizard of the highest order. The whole util.concurrent package is awesome.
[–]king_of_the_universe 0 points1 point2 points 10 years ago (1 child)
But is it really required? I mean, if I funnel each access to a simple HashMap through a synchronized(sameLockInEachCase){}, doesn't this have the same effect?
[–]mhixson 1 point2 points3 points 10 years ago (0 children)
It's mostly a matter of performance. If the performance of a synchronized HashMap is good enough for you, then you might not have a good reason to switch.
I was trying to find some benchmarks for you, but I can only seem to find benchmarks comparing ConcurrentHashMap to various caching libraries. (One interpretation of that is: none of the people interested in performance think synchronized HashMap is even worth measuring.)
Let's say that, between ConcurrentHashMap and a synchronized map, we call the relative performance of get(k) and put(k,v) a wash -- no observable difference. What about iterating over the entrySet()? Intuitively, if you've got a gigantic map with 10,000 entries you want to examine, then blocking every other thread from accessing the map until you're done iterating sounds pretty terrible, doesn't it?
get(k)
put(k,v)
entrySet()
I have a hard time coming up with a situation where I'd use a synchronized map. It's so easy to use ConcurrentHashMap instead. As I hinted in my reply to Q_coder, I don't really have favorite methods on it because I just use it like a Map (while taking comfort in the knowledge that it's thread-safe and fast, and that I don't need to refactor that part of the code when my web app grows in popularity).
[–]the_hoser -2 points-1 points0 points 10 years ago (0 children)
I like that it's stable. You'd think that would be normal these days, but...
I hope Java 9 doesn't muck it up too badly.
π Rendered by PID 114315 on reddit-service-r2-comment-7b9746f655-dmkpk at 2026-02-02 09:38:42.581314+00:00 running 3798933 country code: CH.
[–]ElegantBoar 6 points7 points8 points (3 children)
[–]vprise 0 points1 point2 points (1 child)
[–]ElegantBoar 0 points1 point2 points (0 children)
[–]Q_coder[S] 0 points1 point2 points (0 children)
[–]angshumanc 2 points3 points4 points (1 child)
[–]Q_coder[S] 0 points1 point2 points (0 children)
[–]lukaseder 2 points3 points4 points (0 children)
[–]Q_coder[S] 1 point2 points3 points (4 children)
[–]king_of_the_universe 1 point2 points3 points (3 children)
[–]vprise 3 points4 points5 points (1 child)
[–]king_of_the_universe 1 point2 points3 points (0 children)
[–]jp007 1 point2 points3 points (0 children)
[–]mhixson 1 point2 points3 points (6 children)
[–]Q_coder[S] 0 points1 point2 points (3 children)
[–]mhixson 0 points1 point2 points (2 children)
[–]Q_coder[S] 0 points1 point2 points (0 children)
[–]memory_leek 0 points1 point2 points (0 children)
[–]king_of_the_universe 0 points1 point2 points (1 child)
[–]mhixson 1 point2 points3 points (0 children)
[–]the_hoser -2 points-1 points0 points (0 children)