Author: alegru

We can convert float to String in Java using the following methods: String.valueOf() method Float.toString() method Convert float to String in Java using the String.valueOf() method There are multiple overloaded versions of the valueOf() method from the String class. We will use the one which accepts float. Example class Test { public static void main(String[] args)…

Read More Convert float to String in Java

Converting a Java String to a Double is a common task in Java programming. Whether you need to perform mathematical calculations or simply display numeric values, it’s important to know how to convert Strings to Doubles accurately and efficiently. In this tutorial, I will guide you through the process of converting a Java String to…

Read More Java String to a Double Conversion: Tips and Best Practices

In one of the previous posts, we covered the conversion of a Decimal to Hexadecimal. Here, you will learn how to convert Hexadecimal to Decimal in Java. We will explore the following ways: Using the parseInt() method Using custom logic Convert Hexadecimal to Decimal in Java using the parseInt() method Integer class has a static…

Read More Convert Hexadecimal to Decimal in Java

There are two ways to convert Decimal to Hexadecimal in Java: Using the toHexString() method  With a custom logic Convert Decimal to Hexadecimal in Java using the toHexString() method The easiest way is to use the ToHexString() static method of the Integer class to get the Hexadecimal String of a Decimal number. Example class Test { public…

Read More Convert Decimal to Hexadecimal in Java

Want to learn how to merge two ArrayLists in Java? In this post, we will cover the following ways: Using the List.addAll() method Using the Java 8 Streams Using the ListUtils.union() method Merge two ArrayLists in Java using the List.addAll() method There is addAll() method from the List interface that appends all of the elements in…

Read More How to merge two ArrayLists in Java?

In this post, you will learn how to Serialize and Deserialize an ArrayList in Java using the FileOutputStream and FileInputStream classes. How to Serialize an ArrayList in Java? Serialization is the process of changing the state of an object into a byte stream. For example, we use it to write some Java objects into a file. In…

Read More Serialize and Deserialize an ArrayList in Java

Need to remove a character from String in Java?  You can do that by converting the String to a StringBuilder class and using the deleteCharAt() method that removes the character at a specified position. Example class Test { public static void main(String[] args) { String str = “Learn Java”; str = new StringBuilder(str).deleteCharAt(5).toString(); System.out.println(str); } }…

Read More Remove a Character from String in Java