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 moreHow 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 moreHow 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 moreHow 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 moreHow 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 moreCreating 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 moreHow 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 moreHow 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 moreHow 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 moreOverview 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 moreJava 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 moreClasses 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 moreJava 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 moreIntroduction 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 moreJava 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 moreJava'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 moreJava 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 moreJava 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 moreComprehensive 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 moreJava 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 moreJava 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 moreUnderstanding 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 moreHow 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 moreJava 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 moreHow 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 moreHow 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 moreHow 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 moreJava - 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 moreHow 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 moreJava 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 moreJava ArrayList Methods With Examples
In this post we cover the most common Java ArrayList methods with code examples for each method.
Read more
Read moreJava 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 moreJava Remove Duplicates From List
This post provides examples, showing how to remove duplicate items from an ArrayList in Java.
Read more
Read moreHow 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 moreJava 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 moreExtract 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 moreJava 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 moreHow 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 moreJava 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 moreJava - 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 moreEasiest 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 moreHow 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 moreJava 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 moreDifferent 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 moreHow 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 moreHow to Parse JSON in Java
In this tutorial we will look at how to parse JSON in Java using different libraries.
Read more
Read morePurpose of Overriding toString() Method in Java
What is the purpose of toString()
method in Java?
Read more
Read moreJUnit 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 moreHow 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 moreConvert List to Array in Java
Converting between List and Array is a very common operation in Java.
Read more
Read moreJava 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 moreJava 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 moreRead 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 moreRun 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