Category: java-programs
Shell Sort Java Program
This tutorial shows how to write Shell sort program in Java. Shell sort is also an in place sorting algorithm like Bubble sort, Selection sort but it is faster than these algorithms. Shell sort algorithm Shell sort is based on Insertion sort and it improves on it to make sorting…
Merge Sort Java Program
Insertion Sort Java Program
This tutorial shows how to write Insertion sort program in Java. Insertion sort is considered the best among the three simple sorting algorithms, the other two simple sorting algorithms are Bubble sort and Selection sort. Though the time complexity of Insertion sort is also O(n2) but it is considered much…
Selection Sort Java Program
Bubble Sort Java Program
This tutorial shows how to write Bubble sort program in Java. Bubble sort is considered the simplest sorting algorithm out of the three simple sort algorithms, other two being Selection sort and Insertion sort, that work by comparing and swapping elements in each pass. Since there are a large number…
Generic Bubble Sort Java Program
In this post we’ll see how to write a Bubble Sort program as a Generic class in Java which can be used with arrays of different data types. Bubble Sort- Java Generic class In the generic class used for Bubble Sort we use a bounded parameter to restrict the type…
How to Convert float to int in Java
In this post we’ll see how to convert float to int in Java. Considerations while converting float to int in Java While converting float to int two things you need to consider are- Range of float is more than the int, if the float you are trying to convert to…
How to Convert String to Byte Array in Java
This post shows how you can convert String to a byte array (Byte[]) in Java. Options for converting String to byte array in Java String class in Java has a getBytes() method to encode String into a sequence of bytes. This method has two overloaded variants too where you can…
How to Convert File to Byte Array in Java
This post shows different ways to convert file to byte array in Java. You can use read(byte[] b) method of FileInputStream class which reads up to b.length bytes of data from this input stream into byte array. See example. Java 7 onward you can use Files.readAllBytes() method which reads all…
Shell Sort Java Program
This tutorial shows how to write Shell sort program in Java. Shell sort is also an in place sorting algorithm like Bubble sort, Selection sort but it is faster than these algorithms. Shell sort algorithm Shell sort is based on Insertion sort and it improves on it to make sorting…
Merge Sort Java Program
Insertion Sort Java Program

This tutorial shows how to write Insertion sort program in Java. Insertion sort is considered the best among the three simple sorting algorithms, the other two simple sorting algorithms are Bubble sort and Selection sort. Though the time complexity of Insertion sort is also O(n2) but it is considered much…
Selection Sort Java Program
Bubble Sort Java Program

This tutorial shows how to write Bubble sort program in Java. Bubble sort is considered the simplest sorting algorithm out of the three simple sort algorithms, other two being Selection sort and Insertion sort, that work by comparing and swapping elements in each pass. Since there are a large number…
Generic Bubble Sort Java Program
In this post we’ll see how to write a Bubble Sort program as a Generic class in Java which can be used with arrays of different data types. Bubble Sort- Java Generic class In the generic class used for Bubble Sort we use a bounded parameter to restrict the type…
How to Convert float to int in Java
In this post we’ll see how to convert float to int in Java. Considerations while converting float to int in Java While converting float to int two things you need to consider are- Range of float is more than the int, if the float you are trying to convert to…
How to Convert String to Byte Array in Java
This post shows how you can convert String to a byte array (Byte[]) in Java. Options for converting String to byte array in Java String class in Java has a getBytes() method to encode String into a sequence of bytes. This method has two overloaded variants too where you can…
How to Convert File to Byte Array in Java
This post shows different ways to convert file to byte array in Java. You can use read(byte[] b) method of FileInputStream class which reads up to b.length bytes of data from this input stream into byte array. See example. Java 7 onward you can use Files.readAllBytes() method which reads all…