Bubble Sorting

Java implementation of the Bubble Sort Algorithm Java package com.example; public class BubbleSort { public static void main(String[] args) { int[] toSort = { 2, 9, 3, 6, 1, 0, 4, 5, 8, 7 }; System.out.print("Given Array: "); for (int i = 0; i < toSort.length; i++) { System.out.print(toSort[i] + " "); } int temp; ...

Searching files for the list of keywords

Description : Following program can be used to search the files(java,jsp and js) for the given list of keywords. If present, the absolute path and Line number of occurrence will be written to the text file.   Java package com.example; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.LineNumberReader; import java.util.ArrayList; import java.util.Iterator; public class ContentSearching ...

Patterns

The codes under the Patterns section can be used to print various patterns of numbers &/or stars(*). The specific pattern to be printed is specified on the program page. The basic purpose here is to give the feel of the logic. Being similar to C/C++, the logic codes may be useful in these languages too, ...

Pattern-9

Description:          This program prints the following pattern:                                         ********                                         ***  ***                                         **    **                                         *      *                                         **    **                                         ***  ***                                         ******** Primary Inputs:    None Primary Output:    The pattern specified above Platform Used:      JDK 1.6 with JCreator   Java class Pattern9 { public static void main(String args[]) { String s1 = "*"; int i, j, l = 8, x = 8, y ...

Pattern-8

Description:          This program prints the following pattern(Vertical Histogram):                                     if the array is of elements -|3|7|2|5|                                                                              *                                      *                      ...

Pattern-7

Description:          This program prints the following pattern(Horizontal Histogram):                                     if the array is of elements -|3|7|2|5|                                      ***                                      *******                                      **                                    ...

Pattern-6

Description:          This program prints the following pattern:                                      1                                     121                                   12321                                 1234321                               123454321 Primary Inputs:    Generates a single digit random number Primary Output:    The pattern specified above Platform Used:      JDK 1.6 with JCreator   Java //Primary Input : Generates a single digit number (n) representing the number of lines /* Primary Output: The following pattern is ...

Pattern-5

Description:          This program prints the following pattern: * ** *** **** 1234    *  ** ******* Primary Inputs:    Generates a single digit random number Primary Output:    The pattern specified above Platform Used:      JDK 1.6 with JCreator   Java //Primary Input : Generates a single digit number (n) representing the number of lines /* Primary Output: The following pattern is generated for ...

Pattern-4

Description:          This program prints the following pattern:                                      0                                      12                                      345                                      6789                                      01234 Primary Inputs:    Generates a single digit random number Primary Output:    The pattern specified above Platform Used:      JDK 1.6 with JCreator   Java //Primary Input : Generates a single digit number (n) representing the number of lines /* Primary Output: The following pattern is generated for n lines ...

Pattern-3

Description:          This program prints the following pattern:                                      0                                      10                                      101                                      0101                                      01010  Primary Inputs:    Generates a single digit random number Primary Output:    The pattern specified above Platform Used:      JDK 1.6 with JCreator   Java //Primary Input : Generates a single digit number (n) representing the number of lines /* Primary Output: The following pattern is generated for n lines ...