Java Programming Tips


Java Byte Code Modification Using Cglib and Asm

This article looks at how cglib library can be used for java byte code manipulation at runtime. A number of popular java projects such as spring framework, guice and hibernate internally use cglib for byte code manipulation. Byte code modification enables manipulation or creation of new classes after compilation phase of java applications. In java, […]

How to Create a Fat Jar Using Maven

Maven is a popular build tool for Java projects. Using Maven it is possible specify all the third party dependencies of a project. During Java compilation, Maven adds these dependency library jars  automatically to the classpath. Maven can also be used to package a project as a distributable jar library. However when you package a […]

How to Generate all Permutations of a String in Java

The following Java program generates all the permutations of a string. It also eliminates any duplicate strings generated. This program can be used to generate anagrams. Note that the following program generates permutations in a case insensitive manner. Hence original case of the input string is not preserved in the permutations. The following program uses […]

How to Check if Two Words are Anagrams in Java

Permutations of a word are generated by shuffling the letters in the word. The full set consists of all permutations of the letters in a word. However only a subset of these are valid words in English language. These valid word combinations of letters is known as the Anagram for the original word and vice […]

How to Find Sum of Digits of a Number in Java

The following Java program computes the sum of digits of a number. For example, if the input is 278, the output is calculated as 2+7+8 = 17. This function is useful in a number of numeric algorithms. For example,  IMEI check sum algorithm requires calculation of sum of digits. This problem is also given as […]