Posts from Java

Remove leading and trailing spaces from a string in Java

By Sai Venkat Kodithyala

In this tutorial, we are learning how to remove leading and trailing spaces from a string in Java. We can remove leading and trailing spaces from a string using these methods: trim.... Read More

How to remove leading zeros from a string in Java

By Aakash Puri

In this tutorial, you’ll learn how to remove leading zeros from a given string in Java. There are many ways in which you could do that. For example, use string functions or c.... Read More

How to send Email with attachment in Java Eclipse

By Smitha S Maganti

Hello, in this tutorial, you will learn how to send an email with an attachment using Java Eclipse. The easiest way to do this is by converting the Java project to a Maven project .... Read More

How to throw an exception in Java

By Tishya Thakkar

In this tutorial, we will learn how to throw an exception in Java. We use exceptions in Java to check for errors at compile-time instead of runtime. We can also create custom excep.... Read More

Detect and Extract URL from String in Java

By Pratiksha Bhandari

In this tutorial, we will look at one of the interesting concepts of Java. Suppose you are given so long text with some URLs in it and your work is to fetch those URLs then how wil.... Read More

Implementing Positive and Negative Infinity in Java

By Sai Venkat Kodithyala

In this tutorial, we are learning how to implement infinity in Java. We will implement both positive and negative infinity here. Positive Infinity in Java Let’s see how we ca.... Read More

How to Initialize a Byte Array in Java?

By Pratiksha Bhandari

In this tutorial, we will learn how to initialize a byte array in Java. What is a byte? We all know that 8 bits = 1 byte or we can say a combination of eight zeros and ones. A byte.... Read More

How to Return an Array in Java

By Tishya Thakkar

In this tutorial, we will learn how to return an array in java. Returning an array in Java Step 1: You have to declare the return type of the method as an array of the data type y.... Read More