I was proting some code from C# to Java, that code was using the struct KeyValuePair , this struct is pretty handy when you want to return a single key/value object without defining a Dictionary object that will contain only one element.

In Java there is no matching class defined in core Java APIs that match the .NET KeyValuePair class, but such class can be found in the apache.commons.collections API and its called DefaultKeyValue.

Although there is another option in Java core APIs, its the  java.util.Properties, but i didn't like it.

 

 

 

so-hiring

Recommended Articles

Join our subscribers

Sign up here and we'll keep you updated on the latest in product, UX, and engineering from HubSpot.

Subscribe to the newsletter