Java Programming Tips


Java Listing All Files In a Directory

One of the common file system needs during programming is to find all the files or subdirectories in a directory. In Java, it is pretty easy since java.io.File has simple methods to achieve this. The File class is capable of representing both files and directories. This enables us to handle them in identical fashion, but […]

Convert String to Date in Java

Java has a dedicated class for representing and manipulating dates. This full package name of this class is java.util.Date. However when we receive date from external sources such as web services, we receive them as a String. The format of this date string depends on the source of the data. Hence we require conversion from […]

Java program to find average of numbers in an array

One of the common numerical needs in programs is to calculate the average of a list of numbers. This involves taking the sum of the numbers and then dividing the result with the count of numbers.The following example illustrates the algorithm of finding average of a list of numbers, Numbers are 12, 45, 98, 33 […]

Java Decimal to Hexadecimal Conversion

In Mathematics, we use various positional numbering schemes for representing numbers. We are familiar with decimal numbering system which uses a base of 10. Two other commonly used numbering systems in computing are hexadecimal (base 16) and binary (base 2). Conversion of decimal value to hex string requires the following steps, Find the reminder of […]

Java Hexadecimal to Decimal Conversion

In Mathematics, we use various positional numbering schemes for representing numbers. We are familiar with decimal numbering system which uses a base of 10. Two other commonly used numbering systems in computing are hexadecimal (base 16) and binary (base 2). When we represent a number in hexadecimal system, we use the symbols 0 to 9 […]