Home » Java » Core Java » Page 5

Core Java

Locking for multiple nodes the easy way: GCS

It happens to all of us. We develop stateless applications that can scale horizontally without any effort.However sometimes cases arise where you need to achieve some type of coordination. You can go really advanced on this one. For example you can use a framework like Akka and it’s cluster capabilities. Or you can go really simple like rolling a mechanism ...

Read More »

Java String to String Array Conversion Examples

A quick and practical guide on how to convert String to String Array in differnet ways in java. 1. Overview In this article, you’ll learn how to convert String to String Array in java with example programs. Let us learn the different ways to do the conversion into a string array. from a string value. 2.  Using the split() method ...

Read More »

Java Program To Get Union Of Two Arrays

A quick and programming guide to how to get the union of two unsorted arrays in java with example programs. 1. Overview In this article, you’ll learn how to get the union of two arrays in java.  A union set is all the values of two sets or from all collection. We can do the union function in java using ...

Read More »

Java Program to Calculate Average Using Arrays

A quick and practical guide to find and to calculate the average of numbers in array using java language. 1. Overview In this article, you’ll learn how to calculate the average of numbers using arrays.  You should know the basic concepts of a java programming language such as Arrays and forEach loops. We’ll see the two programs on this. The ...

Read More »

10 Examples of ConcurrentHashMap in Java

Hello guys, if you are new to Java programming and want to learn ConcurrentHashMap class in Java then you have come to the right place. Earlier, I have shared the best books and best courses to learn Java, and today, I am going to share 10 examples of using ConcurrentHashMap in Java. As a Java programmer, you might have heard about ...

Read More »

Using Java 9 Modularization to Ship Zero-Dependency Native Apps

Why can’t I just build an .EXE? When Java was first introduced, mainstream programming languages mostly either compiled to standalone executables (e.g. C/C++, COBOL), or else ran in an interpreter (e.g. Perl, Tcl). For many programmers, Java’s need for both a bytecode compiler and a runtime interpreter was a shift in thought. The compilation model made Java better suited for ...

Read More »

Testing with Hoverfly and Java Part 3: State

Previously we simulated a delay scenario using Hoverfly. Now it’s time to dive deeper and go for a state-based testing. By doing a stateful simulation we can change the way the tests endpoints behave based on how the state changed. Hoverfly does have a state capability. State in a hoverfly simulation is like a map. Initially it is empty but ...

Read More »

Testing with Hoverfly and Java Part 2: Delays

On the previous post we implemented json and Java based Hoverfly scenarios..Now it’s time to dive deeper and use other Ηoverfly features. A big part of testing has to do with negative scenarios. One of them is delays. Although we always mock a server and we are successful to reproduce erroneous scenarios one thing that is key to simulate in ...

Read More »

Keeping the Caller Busy

There are ways we could refactor the displayCart function, but consider a second what the caller is doing each time it wants to use the function. Consider this simple code example: 01 02 03 04 05 06 07 08 09 10 11 12 13 // caller String shoppingCartMessage = displayCart("You have %s", cart.size());   String otherMessage = displayCart("You saved %s", ...

Read More »