development

How to Iterate a List of Maps in Java

In this blog post, we will explore different techniques to iterate through a list of maps in Java, providing you with the knowledge and tools to efficiently work with such data structures.

Read more

Read more
development

How to Sort a Map in Java

Maps in Java are an essential part of any developer’s toolkit. They provide a powerful way to associate keys with values, but by default, they don’t maintain any specific order. Sometimes, though, we may need to sort the elements of a map based on certain criteria. Fortunately, Java provides several approaches to achieve this. In this blog post, we’ll explore different methods to sort a map in Java.

Read more

Read more
development

How to Convert a Java 8 Stream to an Array

Java 8 introduced the Stream API, which provides a powerful way to process collections of data in a functional and declarative manner. Streams offer numerous operations to manipulate data, such as filtering, mapping, and reducing, making them an essential part of modern Java development. At times, it may be necessary to convert a Stream back into a more traditional data structure like an array. In this article, we will explore various methods to convert a Java 8 Stream to an array.

Read more

Read more
development

How to Generate Random Integers Within a Specific Range in Java

Generating random integers within a specific range is a common requirement in various Java applications. Whether you’re building a game, conducting simulations, or implementing algorithms that require randomization, Java provides built-in mechanisms to generate random integers efficiently. In this blog post, we’ll explore different approaches to accomplish this task, providing code examples and explaining their pros and cons.

Read more

Read more
development

How to Map a JSON String to a Java Object

In modern software development, the use of JSON (JavaScript Object Notation) has become prevalent for data exchange between applications. Mapping JSON strings to Java objects is a common requirement in many projects. In this blog post, we will explore two popular libraries, Jackson and Gson, to demonstrate how to map a JSON string to a Java object. Let’s dive in!

Read more

Read more
development

Creating a Table with Java JDBC Statement

In Java, the JDBC (Java Database Connectivity) API provides a standard way to interact with databases. With JDBC, you can perform various database operations, including creating tables. In this tutorial, we’ll explore how to create a table using Java JDBC statements.

Read more

Read more
development

How to Filter a Map in Java

In Java, maps provide a convenient way to store key-value pairs. Filtering a map involves selectively extracting elements based on specific conditions. Whether you want to remove certain entries or create a new map with filtered data, this article will guide you through various techniques for filtering maps in Java.

Read more

Read more
development

How to Switch Between Different Java Versions on Mac

To switch between different versions of Java on your Mac, you can use the jenv tool in combination with Homebrew. Here’s a step-by-step guide:

Read more

Read more
development

How to Use Brew to Install Java on Mac

In this article we show how to install Java on Mac using Homebrew, and how to allow to switch between different versions such as Java8, Java11, Java13 and latest Java version.

Read more

Read more
development

Overview of Java Exceptions and How to Handle Them

Java Exceptions are disruptions that occur during the execution of a program, potentially leading it to terminate abruptly. Exception handling enables programmers to foresee and address these issues, directing the program along alternative paths when an exception occurs.

Read more

Read more
development

Java Access Modifiers: Public, Private, Protected

Access modifiers in Java determine the scope and accessibility of classes, interfaces, variables, and methods. They help to ensure that data and methods are accessible only to the intended parts of the code. Java has four types of access modifiers: public, private, protected, and the default (no modifier). Let’s discuss each one with examples.

Read more

Read more
development

Classes and Objects in Java: A Beginner’s Guide

In Java, classes and objects are fundamental building blocks that facilitate the core concept of object-oriented programming (OOP). In this tutorial, we’ll explore what classes and objects are and illustrate their use in Java with code examples.

Read more

Read more
development

Java Object-Oriented Programming Concepts

Object-Oriented Programming (OOP) is a programming paradigm based on the concept of “objects,” which contain data and the functions to manipulate that data. This post provides an overview of the foundational principles of OOP in Java, suitable for beginners and intermediate programmers.

Read more

Read more
development

Introduction to Java Methods

A method in Java is a block of code that performs a specific task or operation. It is defined within a class and can be called (invoked) from other parts of the program. Methods allow you to encapsulate logic, making your code more modular and easier to understand.

Read more

Read more
development

Java Arrays Tutorial with Code Examples

In Java, arrays are objects, and they provide a way to store a fixed-size sequential collection of elements. This tutorial will introduce the basics of using arrays in Java.

Read more

Read more
development

Java's Break and Continue Statements with Code Examples

The break and continue statements, are frequently used to alter the default behavior of loops. In this blog post, we’ll go through the concepts of break and continue, understand their usage, and explore real-world code examples to illustrate their practical applications.

Read more

Read more
development

Java While and Do-While Loops with Code Examples

In this guide, we will delve into two fundamental types of loops in Java: the while loop and the do-while loop. We’ll explore their differences, use cases, and provide illustrative code examples to help you grasp their concepts effectively.

Read more

Read more
development

Java for loop Statement with Code Examples

In this blog post, we will delve into the Java for loop statement, providing a detailed explanation along with various code examples to illustrate its usage.

Read more

Read more
development

Comprehensive Guide to Java Operators with Code Examples

In this blog post, we’ll explore the different types of Java operators, their usage, and provide code examples along with their outputs.

Read more

Read more
development

Java Control Flow Statements: if...else and switch

In Java, there are a number of ways we can control the flow of the program. Control flow statements, change or break the flow of execution by implementing decision making statements.

Read more

Read more
development

Java Switch Statement With Examples

The Java programming language offers various control structures to handle these situations efficiently. One such structure is the “switch statement”, a powerful tool for executing different blocks of code based on the value of an expression. In this blog post, we will explore the Java switch statement, its syntax, use cases, and provide some examples to better understand its functionality.

Read more

Read more
development

Understanding Java's Key Features

In this blog post, we will explore some of Java’s key features that have contributed to its enduring success.

Read more

Read more
development

How to Create a Temporary File in Java

There are times when we need to create temporary files on the fly to store some information and delete them afterwards.

Read more

Read more
development

Java 8 Streams Tutorial With Code Examples

In this blog post, we are going to discuss Java 8 Streams features and provide lots of different code examples.

Read more

Read more
development

How to Check if a File or a Directory Exists in Java

In Java, there are two primary methods of checking if a file or directory exists. These are:

Read more

Read more
development

How to Run JUnit 5 Tests in a Specific Order

By default, JUnit runs tests in an unpredictable order. There are times when you want to run your tests in a specific order.

Read more

Read more
development

How to Read Files in Java

Java provides several methods to read files. Each of these methods is appropriate for reading different types of files in different situations. Some are better for reading longer files, others are better for reading shorter ones, etc.

Read more

Read more
development

Java - How to Read JSON File as String

In this post we will look at how to read a JSON file as a String variable in Java. This is sometimes useful, especially in API testing when you want to POST a JSON payload to an endpoint.

Read more

Read more
development

How to Delete Files and Directories in Java

To delete a file in Java, we can use the delete() method from Files class. We can also use the delete() method on an object which is an instance of the File class.

Read more

Read more
development

Java Generics Tutorial - What are Generics and How to Use Them?

Java Generics is one of the most important features of the Java language. The idea behind generics is quite simple, however, it sometimes comes off as complex because of the shift from the usual syntax associated with it.

Read more

Read more
development

Java ArrayList Methods With Examples

In this post we cover the most common Java ArrayList methods with code examples for each method.

Read more

Read more
development

Java Compare Two Lists

The List interface in Java provides methods to be able to compare two Lists and find the common and missing items from the lists.

Read more

Read more
development

Java Remove Duplicates From List

This post provides examples, showing how to remove duplicate items from an ArrayList in Java.

Read more

Read more
development

How to Install IntelliJ on Mac OS Using Brew

In this post, we look at how to use brew to install IntelliJ Community Edition and Ultimate Edition.

Read more

Read more
development

Java Get Current Working Directory

How to get the current working directory in Java? The current working directory means the root folder of your current Java project.

Read more

Read more
development

Extract Numbers From String Using Java Regular Expressions

The following are examples which show how to extract numbers from a string using regular expressions in Java.

Read more

Read more
development

Java Get Current Date Time

How to get the current date and time in Java? In this tutorial we’ll look at three different methods in Java 8.

Read more

Read more
development

How to Convert Java Object to JSON

In this tutorial we show how to convert a Java object to JSON using two libraries, Jackson and Gson.

Read more

Read more
development

Java Write To File Examples

In this post we will look at five different examples on how to write to a file using Java. The code sinppets check to see if the file exists before writing to the file, otherwise a file is created.

Read more

Read more
development

Java - How to Convert String to Int With Examples

How to convert a String to an Int in Java? If the String contains only numbers, then the best way to convert the String to Int is by using Integer.parseInt() or Integer.valueOf().

Read more

Read more
development

Easiest Way to Reverse a String in Java

Reversing a string is one of the most frequently asked questions in a Java technical interview. The Interviewers may ask you to write different ways to reverse a string, or they may ask you to reverse a string without using in-built methods, or they may even ask you to reverse a string using recursion.

Read more

Read more
development

How to Convert Java Map to JSON

There are a number of ways to convert a Java Map into JSON. It is quite common to convert Java Arrays and Maps into JSON and vice versa.

Read more

Read more
development

Java Loop Through List

In this tutorial, we look at five different ways we can iterate through an ArrayList in Java. As of Java 8, we can use the forEach method as well as the iterator class to loop over an ArrayList.

Read more

Read more
development

Different Ways to Iterate Through a Map in Java

Looping over a Map in Java. In this post, we look at four different ways we can iterate through a map in Java. As of Java 8, we can use the forEach method as well as the iterator class to loop over a map.

Read more

Read more
development

How to Encode and Decode JSON Byte Array

The typical way to send binary in JSON is to base64 encode it. Java provides different ways to Base64 encode and decode a byte[]. One of these is DatatypeConverter.

Read more

Read more
development

How to Parse JSON in Java

In this tutorial we will look at how to parse JSON in Java using different libraries.

Read more

Read more
development

Purpose of Overriding toString() Method in Java

What is the purpose of toString() method in Java?

Read more

Read more
development

JUnit 5 Annotations With Examples

JUnit 5 is the next generation of JUnit. The goal is to create an up-to-date foundation for developer-side testing on the JVM. This includes focusing on Java 8 and above, as well as enabling many different styles of testing.

Read more

Read more
development

How to Compare Strings in Java

In order to compare Strings for equality, you should use the String object’s equals or equalsIgnoreCase methods. We will also see why we should not use the == operator to compare strings.

Read more

Read more
development

Convert List to Array in Java

Converting between List and Array is a very common operation in Java.

Read more

Read more
development

Java Create File Examples

Creating files in Java is easy. In this post, we’ll look at four different ways to create files in Java. All we need to do is import the relevant package and use relevant methods.

Read more

Read more
development

Java Random Number Generation

Generating random numbers in Java is a common task. For example, you might want to execute tests with random values each time. In this post, we look at different ways we can generate random numbers in Java.

Read more

Read more
development

Read Properties File in Java With ResourceBundle

There are a number of ways to load and read properties file from Java, but the easiest and most straightforward is using the ResourceBundle class.

Read more

Read more
development

Run All Test Classes in a Package from testng.xml Suite

<suite name="Suite1" verbose="1">
    <test name="all-tests">
        <packages>
            <package name="io.devqa.tests.ui"/>
        </packages>
    </test>
</suite>

Read more

Read more