How to Convert an Integer to Octal in Java

Java wrapper class Integer provides an utility function toOctalString(int) which returns an integer in octal form. However, in this post, we will also see an example on how we can convert integer to octal form mathematically without using Java API classes. If you divide a number with 8, what you get in the reminder is … Read more

How to Reverse an Integer in Java

In this example, we will see how to reverse an integer in Java using mathematical equations, StringBuffer and StringBuilder classes. Reverse an Integer in Java using Mathematical Equations To reverse an integer mathematically, first thing what we should do is to take out the last digit as a separate integer. That is possible by dividing … Read more

Bubble Sort

What is Bubble Sort? Bubble sorting algorithm sort items in a list by repeatedly comparing adjacent elements and swapping them when they are out of order and this process is repeated until it sort the entire list. Bubble Sort Animation A picture is worth a thousand words. I found this interesting bubble sort gif file … Read more

How to read input from User in Java

In this post, we will discuss on how to read input from User using Scanner and InputStreamReader. Scanner(System.in) To read values of known type from standard input, we can use Scanner class. When I say known types, any primitive like int, double, char or a String. Scanner provides various utility methods to read input such … Read more