Home » Java » Core Java » Page 9

Core Java

Java 14 New Features

On 17th March 2020, Oracle has released a new version of Java named Java 14, which includes lots of new features, improvements in tooling, security, debugging, and updated documentation. However Oracle also provides you with the older version of Java as backward compatibility so your previous code can still run on older versions, and it’s not that Java 14 has ...

Read More »

How to convert String to int in Java

In this tutorial, we will see the various ways in which we can convert String to int(or Integer) in Java. You can use any of the following ways : – Using Integer.parseInt(string) – Using Integer.valueof(string) – Using Apache commons NumberUtils.toInt(string) – Using Apache commons  NumberUtils.createInteger(string) – Using Guava library’s Ints.tryParse(string) method – Using Integer.decode(string) – Using new Integer(string) Using Integer.parseInt(string) String ...

Read More »

7 JVM arguments of Highly Effective Applications

At the time (March 2020) of writing this article there are 600+ arguments that you can pass to JVM just around Garbage collection and memory. If you include other aspects, total JVM arguments count will easily cross 1000+. 😊. It’s way too many arguments for anyone to digest and comprehend. In this article, we are highlighting seven important JVM arguments ...

Read More »

Hands on Optional value

Optional is in air due to coronavirus, everything is becoming optional like optional public gathering , optional work from home, optional travel etc. I though it is good time to talk about real “Optional” in software engineering that deals with NULL reference. Tony Hoare confessed that he made billion dollar mistake by inventing Null. If you have not seen his ...

Read More »

How to create immutable Map in Java

Hello Friends, In this tutorial, we will see how we can create an immutable Map in Java. – What does it mean by immutable class or object? – What is an Immutable Map? – How to create an immutable Map in java? What does it mean by immutable class or object? An immutable class or object is a class or ...

Read More »

New features between Java 8 and Java 14

Since version 9, Java has new features every 6 months and it’s very hard to keep track of these new changes. Most of the information on the internet describes changes between the last 2 Java versions. However, if you’re in a similar situation as me, you’re not using the last Java version but a version several releases older. Then it’s ...

Read More »

Prefixed Naming

If you look at the source code of Takes or Cactoos for the first time, you most probably, like many others, will be triggered by the naming convention, which implies that most class names have two-letter prefixes: BkSafe, RqFake, RsWithStatus, TkGzip, and so on. To be honest, I haven’t seen a single Java developer who would be comfortable with this ...

Read More »

Call That An Exception?

While this is a Java example to do with testing and wiremock, it relates to a more universal problem. We were trying to retry Wiremock’s verify method, which may be called by our test before the endpoint we’re checking is hit. In that situation, we’d want to try again a few seconds later in a loop until timing out. Interesting, ...

Read More »

Mythematical Codey Code

Consider the following snippet: int max = 10; int a = 0; while (true) { // do a thing that may result in an early return if (++a >= max) { break; } } throw new RuntimeException("It ran out of attempts"); There are a few WTFs in the above. The loop’s a bit weird, the flow of control seems to ...

Read More »