- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9291 Articles for Object Oriented Programming
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
221 Views
Gnome Sort works with one lement at a time and gets it to the actual position. Let us see an example to implement Gnome Sort −Example Live Demoimport java.util.Arrays; public class Demo{ static void gnome_sort(int my_arr[], int n){ int index = 0; while (index < n){ if (index == 0) index++; if (my_arr[index] >= my_arr[index - 1]) index++; else{ int temp = 0; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
226 Views
Following is the Java program to implement Reversal algorithm for array rotation −Example Live Demoimport java.io.*; public class Demo{ static void rotate_left(int my_arr[], int no_of_rotation){ int n = my_arr.length; array_reversal(my_arr, 0, no_of_rotation - 1); array_reversal(my_arr, no_of_rotation, n - 1); array_reversal(my_arr, 0, n - 1); } static void array_reversal(int my_arr[], int start, int end){ int temp; while (start < end) { temp = my_arr[start]; my_arr[start] = my_arr[end]; my_arr[end] = ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
728 Views
Following is the Java Program for Recursive Insertion Sort −Example Live Demoimport java.util.Arrays; public class Demo{ static void recursive_ins_sort(int my_arr[], int arr_len){ if (arr_len = 0 && my_arr[j] > last){ my_arr[j+1] = my_arr[j]; j--; } my_arr[j+1] = last; } public static void main(String[] args){ int my_arr[] = {11, 23, 67, 83, 42, 11, 0}; recursive_ins_sort(my_arr, my_arr.length); System.out.println("The array elements after implementing insertion sort is "); System.out.println(Arrays.toString(my_arr)); } }OutputThe ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Following is the Java Program for Recursice Bubble Sort −Example Live Demoimport java.util.Arrays; public class Demo{ static void bubble_sort(int my_arr[], int len_arr){ if (len_arr == 1) return; for (int i=0; i my_arr[i+1]){ int temp = my_arr[i]; my_arr[i] = my_arr[i+1]; my_arr[i+1] = temp; } bubble_sort(my_arr, len_arr-1); } public static void main(String[] args){ int my_arr[] = {45, 67, 89, 31, 63, 0, 21, 12}; bubble_sort(my_arr, my_arr.length); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
279 Views
A Tetrahedron is a polyhedron composed of four triangular faces, six straight edges, and four vertex corners.Following is the Java program to calculate area of a Tetrahedron −Example Live Demoimport java.io.*; public class Demo{ static double tetra_vol(int side){ double my_vol = (Math.pow(side, 3) / (6 * Math.sqrt(2))); return my_vol; } public static void main(String[] args){ int side = 4; double my_vol = tetra_vol(side); my_vol = (double)Math.round(my_vol * 100) / 100; System.out.println("The area of tetrahedron is"); System.out.println(my_vol); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
315 Views
An array is a linear data structure that is used to store a group of elements with similar datatypes. It stores data in a sequential manner. Once we create an array we can't change its size i.e. it can store a fixed number of elements. The array comes with a vast application and use case. Also, we can perform numerous operations on arrays. This article will help you to understand the basics of arrays and also, we will make java programs to perform right and left rotation operations on arrays. Java Program for Array Rotation First, let's understand the term ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Following is the Java code to print Number srries without using any loop −Example Live Demopublic class Demo{ public static void main(String[] args){ int my_num = 0; System.out.println("The numbers without using loop have been printed below"); print_without_loop(my_num); } public static void print_without_loop(int my_num){ if(my_num
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
139 Views
Following is the Java program for largest K digit number divisible by X −Example Live Demoimport java.io.*; import java.lang.*; public class Demo{ public static int largest_k(int val_1, int val_2){ int i = 10; int MAX = (int)Math.pow(i, val_2) - 1; return (MAX - (MAX % val_1)); } public static void main(String[] args){ int val_1 = 25; int val_2 = 2; System.out.println("The largest 2 digit number divisible by 25 is "); System.out.println((int)largest_k(val_1, val_2)); } }OutputThe largest 2 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
Following is the Java program for longest increasing subsequence −Example Live Demopublic class Demo{ static int incre_subseq(int my_arr[], int arr_len){ int seq_arr[] = new int[arr_len]; int i, j, max = 0; for (i = 0; i < arr_len; i++) seq_arr[i] = 1; for (i = 1; i < arr_len; i++) for (j = 0; j < i; j++) if (my_arr[i] > my_arr[j] && seq_arr[i] < seq_arr[j] + 1) seq_arr[i] = seq_arr[j] + 1; ... Read More