Using Array in JSP


<HTML>

  <HEAD>
    <TITLE>My Array on JSP</TITLE>
  </HEAD>

Java Regular Expression: Split using StringTokenizer

01 // : c12:ReplacingStringTokenizer.java
02 // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
03 // www.BruceEckel.com. See copyright notice in CopyRight.txt.
04 

Counting String Pattern using Regular Expression (Perl, Unix)

Perl
Using "while loop"

1 $count = 0;
2 while (<>) {

Java Regular Expression: Counting Words

Sample program to counting words.

WordCount.java

01 import java.io.FileInputStream;
02 import java.nio.CharBuffer;
03 import java.nio.MappedByteBuffer;

Java Regular Expression: Split

My most programming tasks is processing text. Regular expression of regex is the tool to complete the task. Below is an example to split a data by comma. The result is stored in an array of String. I usually using it to split a CSV file.

import java.util.regex.Pattern;

public final class CSVSplit {

  private static String REGEX = ",";

  private static String INPUT = "one,two,three,four,five";

  public static void main(String[] argv) {
    Pattern p = Pattern.compile(REGEX);
    String[] items = p.split(INPUT);

Insertion Sort

Insertion Sort is one of sorting algorithms. Sometime called by simple insertion sort. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort, but it has various advantages:

  • Simple to implement
  • Efficient on (quite) small data sets
  • Efficient on data sets which are already substantially sorted: it runs in O(n + d) time, where d is the number of inversions
  • More efficient in practice than most other simple O(n²) algorithms such as selection sort or bubble sort: the average time is n²/4 and it is linear in the best case
  • Stable (does not change the relative order of elements with equal keys)
  • In-place (only requires a constant amount O(1) of extra memory space)
  • It is an online algorithm, in that it can sort a list as it receives it.

    Sample code ...

Compute pi value

Pi or π a mathematical constant which represents the ratio of any circle's circumference to its diameter in Euclidean geometry, which is the same as the ratio of a circle's area to the square of its radius. π with 50 digit is approximately equal to 3.14159265358979323846264338327950288419716939937510

The classical formula to compute π is J. Machin (1680-1752)'s formula:

π/4 = 4 * arctan (1/5) - arctan (1/239)

Java program to implement the Machin's formula is ...

Deep Web (Invisible Web)

The deep Web (also called Deepnet, the invisible Web, or the hidden Web) refers to World Wide Web content that is not part of the surface Web, which is indexed by search engines. It is estimated that the deep Web is several orders of magnitude larger than the surface Web.

These types of pages used to be invisible but can now be found in most search engine results:

  • Pages in non-HTML formats (pdf, Word, Excel, PowerPoint), now converted into HTML.
  • Script-based pages, whose URLs contain a ? or other script coding.


Syndicate

Syndicate content

Navigation

AdSense