TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Java 21: What’s New?

144 pointsby agluszakalmost 2 years ago

16 comments

jphalmost 2 years ago
The matching syntax looks really good to me:<p><pre><code> &#x2F;&#x2F; Java 21 if (obj instanceof Point(int x, int y)) { System.out.println(x+y); } &#x2F;&#x2F; Older Java if (obj instanceof Point p) { int x = p.x(); int y = p.y(); System.out.println(x+y); }</code></pre>
评论 #37068493 未加载
评论 #37068148 未加载
评论 #37068660 未加载
评论 #37069201 未加载
评论 #37069694 未加载
评论 #37069005 未加载
评论 #37068159 未加载
theandrewbaileyalmost 2 years ago
&gt; Java collections don’t have a type representing an ordered sequence of elements, Java 21 fills this gap by introducing the SequencedCollection, SequencedSet and SequencedMap interfaces. These interfaces provide methods for adding, modifying or deleting elements at the beginning or end of the collection, as well as for iterating over a collection in reverse order.<p>That sounds like a deque, and it&#x27;s been in Java for a long time. (No set or map implementations though.)<p><a href="https:&#x2F;&#x2F;docs.oracle.com&#x2F;en&#x2F;java&#x2F;javase&#x2F;18&#x2F;docs&#x2F;api&#x2F;java.base&#x2F;java&#x2F;util&#x2F;Deque.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;docs.oracle.com&#x2F;en&#x2F;java&#x2F;javase&#x2F;18&#x2F;docs&#x2F;api&#x2F;java.base...</a>
评论 #37068365 未加载
评论 #37068317 未加载
whalesaladalmost 2 years ago
For those in the ecosystem these days - is there a compelling reason to choose Java over Kotlin? I am under the impression that Kotlin is a better Java without any sacrifices. Is this true?
评论 #37068059 未加载
评论 #37069288 未加载
评论 #37068956 未加载
评论 #37068163 未加载
评论 #37068743 未加载
评论 #37071658 未加载
评论 #37068073 未加载
评论 #37068045 未加载
评论 #37068009 未加载
评论 #37068468 未加载
评论 #37068024 未加载
评论 #37068756 未加载
评论 #37068991 未加载
评论 #37070456 未加载
sohamgovandealmost 2 years ago
Java 21 is great but every enterprise java system I&#x27;ve seen is still stuck on JDK 8
评论 #37070653 未加载
评论 #37071615 未加载
ajdoingnothingalmost 2 years ago
I can&#x27;t wait until major frameworks (such as Spring in version 6.1) support virtual threads. Reactive programming (e.g., Webflux) would become a niche (unless your use case truly requires streaming with a high number of TPS).
LatticeAnimalalmost 2 years ago
The syntax for the string template surprised me. Are there other languages that use a `STR.` prefix to indicate string formatting?
评论 #37068904 未加载
评论 #37068569 未加载
评论 #37068693 未加载
评论 #37069644 未加载
评论 #37068594 未加载
评论 #37068209 未加载
ricticalmost 2 years ago
Are StringTemplates constant? i.e. for this method:<p>StringTemplate foo() { return RAW.&quot;&quot;; }<p>is foo() == foo()?<p>This is a very useful feature of JS tagged template functions, as it lets a template processor do expensive one-time processing of a StringTemplate and cache the result, then use that to quickly apply that to particular values. I don&#x27;t see an answer here: <a href="https:&#x2F;&#x2F;cr.openjdk.org&#x2F;~jlaskey&#x2F;templates&#x2F;docs&#x2F;api&#x2F;java.base&#x2F;java&#x2F;lang&#x2F;StringTemplate.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;cr.openjdk.org&#x2F;~jlaskey&#x2F;templates&#x2F;docs&#x2F;api&#x2F;java.base...</a>
renewiltordalmost 2 years ago
Would be cool if there were an easy way to add primitives to Java. I would like a 128-bit integer that the JVM could handle with `add` + `adc` and friends. If I could extend my JVM trivially by linking in a `.so` that enabled it to handle the primitive it would be pretty sick. I imagine that&#x27;s not really that easy to do, but a nice wide primitive that could be used for fixed point arithmetic would be nice to have.
评论 #37072474 未加载
eastboundalmost 2 years ago
Anyone knows when the Java 21 LTS certification book will be out (“OJP exam” or something like that)?<p>I’m tempted to pass the exam with Java 17, since the wait for Java 21 will be too long, assuming it will be several months after the GA date, September 21st.
评论 #37068489 未加载
kamaalalmost 2 years ago
Did tail call optimisation make it to the JVM so that we can have it in Clojure?
评论 #37072470 未加载
Espionage724almost 2 years ago
For a while I was only interested in newer Java releases just to see if Runescape ran on it :p<p>The usefulness seemed to cut-off with Java 11 though and now the RS Java client is being deprecated.
amaialmost 2 years ago
Is there something like pytorch or tensorflow for doing deep learning with Java nowadays? Can Java be used to create programs running on GPUs?
spockzalmost 2 years ago
It remains a bit bitter sweet to see that so many features that we’ve had for 13+ years in Scala and longer in languages like Haskell and were ridiculed back then, now find their way to mainstream Java.
评论 #37068242 未加载
评论 #37068218 未加载
评论 #37068119 未加载
评论 #37068576 未加载
评论 #37073448 未加载
评论 #37068681 未加载
sigzeroalmost 2 years ago
Is Java 21 the next LTS version?
评论 #37070184 未加载
评论 #37128461 未加载
评论 #37070178 未加载
whartungalmost 2 years ago
Yummy.<p>Java&#x27;s rocket sled continues to burn.
评论 #37068261 未加载
softwaredougalmost 2 years ago
&gt; JEP-448 – Vector API: sixth incubation of this feature. This new version includes bugfixes and performance improvements.<p>Rant:<p>JFC Java, its 2023 and people use Java to run actual databases and develop machine learning infrastructure. Yet the ability to do SIMD in the JVM is on its <i>sixth</i> incubation.
评论 #37069234 未加载
评论 #37071386 未加载
评论 #37072467 未加载
评论 #37069202 未加载
评论 #37070923 未加载