KnpCode
Java, Spring, BigData, Web development tutorials with examples
 
Skip to content
  • Ubuntu
  • Big Data
    • Hadoop Tutorials
  • Java
    • Core Java Tutorials – Beginner
    • Core Java Tutorials – Advanced
    • Java Programs
  • spring
    • Spring Framework
Home Archive by category "java-programs" (Page 3)

Category: java-programs

Quick Sort Java Program

UshaK November 28, 2020 January 8, 2021java-programs java-programs 0

This tutorial shows how to write Quick sort program in Java. Quick sort is also a “divide and conquer algorithm” like Merge sort. Quick Sort Algorithm Quick sort works as follows- Chose an element as pivot and then partition all the elements around that pivot. All the elements having value…

Continue reading

Shell Sort Java Program

UshaK November 27, 2020 January 7, 2021java-programs java-programs 0

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…

Continue reading

Merge Sort Java Program

UshaK November 27, 2020 January 7, 2021java-programs java-programs 0

This tutorial shows how to write Merge sort program in Java. Merge sort is termed as a “divide and conquer algorithm” and it is considered to be more efficient than the simple sort algorithms like selection sort and insertion sort. Merge sort algorithm The algorithm for merge sort is based…

Continue reading

Insertion Sort Java Program

UshaK November 27, 2020 January 7, 2021java-programs java-programs 0

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…

Continue reading

Selection Sort Java Program

UshaK November 26, 2020 January 6, 2021java-programs java-programs 0

This post shows how to write Selection sort program in Java. Selection sort is also an in place sorting algorithm like Bubble sort that works by comparing and swapping elements in each pass. Selection sort algorithm Selection sort works as follows- Start with the left most element (index 0) and…

Continue reading

Bubble Sort Java Program

UshaK November 26, 2020 January 6, 2021java-programs java-programs 0

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…

Continue reading

Generic Bubble Sort Java Program

UshaK October 26, 2020 November 16, 2020java-programs Java generics, java-programs 0

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…

Continue reading

How to Convert float to int in Java

UshaK October 23, 2020 January 20, 2021java-programs java-programs 0

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…

Continue reading

How to Convert String to Byte Array in Java

UshaK October 23, 2020 December 24, 2020java-programs java-programs 3

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…

Continue reading

How to Convert File to Byte Array in Java

UshaK October 22, 2020 December 23, 2020java-programs java IO, java-programs 0

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…

Continue reading

‹12345›»
Privacy Policy | Disclaimer
Powered by Nirvana & WordPress.