Text Editor

Description:           This program creates a simple Text Editor.   Primary Inputs:    —— Primary Output:    Text Editor Platform Used:      JDK 1.5 or higher.  Java /*save file as "editor.java"*/ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.text.*; import java.text.*; import java.util.*; import javax.swing.undo.*; import javax.swing.event.*; import java.net.*; public class editor extends JFrame { // ALL THE VARIABLES ...

Stack in Java

Sample source code for Stack implementation in Java ===================== MyStack.java ===================== Java public class MyStack { private static int[] stackArr = new int[5]; private static int top = -1; public void push(int element) { if (!this.isFull()) { top++; stackArr[top] = element; } else { System.out.print("\nStack Overflow!!\n"); } } public int pop() { int temp = ...

Selection Sort

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

Insertion Sort

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

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|                                      ***                                      *******                                      **                                    ...