Code Comments

Code Comments

Tips and short tutorials on various programming technologies

Code Comments RSS Feed
 
 
 
 

Archive for Performance

In Java, Use StringBuilder When Constructing Large Strings

This bit of advice is not new to me nor to the software development community. But recently I had one of those experiences where I put together a quick solution (to keep my code as simple as possible), and later I ran into a performance problem. And it was because I was violating this principle.
I [...] Read more »

Read from Multiple Text Files in Java

This post explains a way to read from multiple text files. It builds on this post that explains how to iterate over large files line by line without reading them into memory. It also builds on this post about using wildcards to search for files in a directory.
It also allows you to specify whether the [...] Read more »

Convert an int to a long and Vice Versa in Java

OK, first is to discuss the difference between an int and a long. A long is basically a longer version of an int. Or in other words, it can be bigger or smaller than int and consumes more memory. The following code shows how you can find the maximum values for these. The long class [...] Read more »

What Is the Difference Between Arrays and ArrayLists in Java

This will not be an exhaustive answer. To understand the full details, you’ll need to look at the Java documentation provided by Sun Microsystems.
An array in Java is immutable, which means that when you create it, it is stored in a specific place in memory and never moved until it is no longer needed and [...] Read more »