1 2 3 4 5 6 7 8 9 10 Next »

Pair is missing in Java 11. JavaFX is no longer part of the JDK.

Create Date: October 22, 2020 at 06:01 PM         Tag: JAVA         Author Name: Sun, Charles

Five Alternative to Pair Class in Java

Java - How to create new Entry (key, value)

There's public static class AbstractMap.SimpleEntry. Don't let the Abstract part of the name mislead you: it is in fact NOT an abstract class (but its top-level AbstractMap is).

The fact that it's a static nested class means that you DON'T need an enclosing AbstractMap instance to instantiate it, so something like this compiles fine:

Map.Entry entry =
    new AbstractMap.SimpleEntry("exmpleString", 42);

As noted in another answer, Guava also has a convenient static factory method Maps.immutableEntry that you can use.


You said:

I can't use Map.Entry itself because apparently it's a read-only object that I can't instantiate new instanceof

That's not entirely accurate. The reason why you can't instantiate it directly (i.e. with new) is because it's an interface Map.Entry.


Caveat and tip

As noted in the documentation, AbstractMap.SimpleEntry is @since 1.6, so if you're stuck to 5.0, then it's not available to you.

To look for another known class that implements Map.Entry, you can in fact go directly to the javadoc. From the Java 6 version

Interface Map.Entry

All Known Implementing Classes:

Unfortunately the 1.5 version does not list any known implementing class that you can use, so you may have be stuck with implementing your own.

New Comment

Understanding Your Performance Characteristics

Create Date: September 07, 2019 at 10:46 AM         Tag: JAVA         Author Name: Sun, Charles

Performance tuning:

Utilization, Saturation and Errors method (USE)

//check version
lsb_release -a

vmstat 1 10

sudo apt install sysstat
iostat -xm

Performnace measurements:

The higher the latency of an application, the higher it's throughput is.

 

 

 

New Comment

Venkat Subramaniam: Kotlin for Java Programmers

Create Date: August 14, 2019 at 06:17 PM         Tag: KOTLIN         Author Name: Sun, Charles

here's so much you know as a Java programmer and yet there is so much more that Kotlin offers. It's a language that is built on strong foundations and, at the same time, brings along phenomenal concepts to favor low ceremony, fluency, sensible warnings, safe types, pragmatic mixture of object-oriented and functional programming, and so much more.

In this presentation, you'll start with what you already are familiar with, and dive into Kotlin, to learn about its strengths and capabilities.

About Dr. Venkat Subramaniam

Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., creator of agilelearner.com, and an instructional professor at the University of Houston.

He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is a regularly-invited speaker at several international conferences. Venkat helps his clients effectively apply and succeed with sustainable agile practices on their software projects.

Venkat is a (co)author of multiple technical books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer. You can find a list of his books at agiledeveloper.com. You can reach him by email at venkats@agiledeveloper.com.

You can find Venkat on Twitter @venkat_s (https://twitter.com/venkat_s).

what's kotlin:

programming in kotlin

Functions:

For and Range:

when:

Null Type;

functional style: 

extension methods:

00:

classes

Delegation:

Fluency:

New Comment
1 2 3 4 5 6 7 8 9 10 Next »