Category «Java»

Java String comparison. The difference between == and equals().

Many Java beginners find it difficult to differentiate between == operator and the “equals()” method when comparing String variables in Java. They assume that both operations perform the same function and either one can be used to compare two string variables. I have even seen many experienced programmers committing the mistake of using “==” to …

How to convert an ArrayList to array in Java

Today, I will share a very basic Java program that converts an ArrayList to array. For most Java developers this is a routine task, but many new comers to Java have asked me this question of how to convert an array to ArrayList. Here is the example code.

How to write to properties file in Java

One of most visited posts on this blog is How to read properties file in Java. In that post I explained how you can read from a properties file. But many people came to that post searching for an example on how to write to a properties file. So I thought it will be beneficial …