Home » Java » Core Java » Page 6

Core Java

A Java XMPP Load Test Tool

In this article, we will develop an XMPP Load Test Tool written in Java. Table Of Contents 1. Introduction 2. XMPP Load Test tools 3. Prerequisites 4. LoadXmppTest Java program 4.1. Create a new Maven project 4.2. Create the main class 4.3. XmppManager class 4.4. Build 4.5. Load test 5. Summary 6. References 7. Download the Maven project   1. ...

Read More »

How to convert Array to List in Java

Hello Friends, In this tutorial, we will learn, various ways in which we can convert an array to a List. package com.blogspot.javasolutionsguide; import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; public class ArrayToList { public static void main(String[] args) { //Before Java 8 System.out.println("Before JAVA 8........................................"); // 1. ...

Read More »

Java puzzlers from OCA part 6

Even for new Java developers, constructors are probably no big mystery. In essence, when you create an instance of a class, the constructor of this class is started. In the 6th part of Java Puzzlers series, we will see a case related to constructors. 01 02 03 04 05 06 07 08 09 10 public class Puzzler {       public ...

Read More »

That’s Two Hours I Won’t Get Back

As I’ve said before around the subject of linting, there’s a limited benefit of spending time modifying your code just because an automated tool told you to. Worse than that, these tools are not infallible. For example, we’ve been regularly adding an exclusion in for a SpotBugs warning around a perfectly innocuous try-with-resources construct, which it doesn’t quite like in ...

Read More »

Java puzzlers from OCA part 5

In the fifth part of the Java Puzzlers series, we will see something related to X.parseX(String s) methods. You can see what we expect from X.parseX() methods. 1 2 3 4 5 6 7 8 9 public class Puzzler {       public static void main(String[] args){         int i = Integer.parseInt("2");         System.out.println(i); // prints 2         } } We give ...

Read More »

Exact Absolute Integral Numbers in JDK 15

JDK 15 Early Access Build b18 introduced new methods to the Math and StrictMath classes that will throw ArithmeticException on provided values outside the range supported by the methods without overflow. These methods bring to the concept of “absolute value” in Java what the methods such as Math.addExact, Math.subtractExact, and Math.multiplyExact have brought to basic arithmetic functions. Prior to JDK ...

Read More »

Java puzzlers from OCA part 4

In the fourth part of Java Puzzlers, we have something related to char type. 1 2 3 4 5 6 7 8 9 public class Puzzler {       public static void main(String[] args){         char myChar = 'a';         myChar++;           System.out.println(myChar);     } } You may have guessed it. It will print “b” and the reason for it is that char type ...

Read More »

Java puzzlers from OCA part 3

In this third part of Java puzzlers, we will see a surprise in variable naming restrictions. If I show you this, I’m sure you won’t be surprised that this does not compile. static is one of the reserved keywords so why should it work? public class Puzzler { public static void main(String[] args){ int static = 2; } } Now ...

Read More »