<script language ="JavaScript">
function showCode()
{
var blue_words_g="abstract,boolean,break,byte,case,catch,char,"+
"class,const,continue,default,double,do,else,extends,finally,final,"+
"float,for,goto,if,implements,import,instanceof,int,interface,long,"+
"native,new,package,private,protected,public,return,short,static,"+
"strictfp,super,switch,synchronized,this,throw,throws,transient,try,"+
"void,volatile,while";
var red_words_g="Object,List,Integer,Connection";
var green_words_g="implements,void,return";
var codeArray=new Array();
var tt=document.all['code'];
if(tt==undefined){return;}
if(tt.length==undefined)
{
codeArray[0]=tt;
}else
{
codeArray=tt;
}
for(var i=0;i<codeArray.length;i++)
{
var text = codeArray[i].innerHTML;
var blues=blue_words_g.split(",");
var reds=red_words_g.split(",");
var greens=green_words_g.split(",");
t_bigger=/>/gi;
t_litter=/</gi;
t_n=/ *[ ]/gi;
t_blank=/ /gi;
t_tab=/ /g;
text=text.replace(t_bigger,">");
text=text.replace(t_litter,"<");
text=text.replace(t_n," <br>");
text=text.replace(t_blank," ");
text=text.replace(t_tab," ");
text=filterComment(text);
text=filterString(text);
var j=0;
for(j=0;j<blues.length;j++)
{
text=changeColor(text,blues[j],"g","blue");
}
for(j=0;j<reds.length;j++)
{
text=changeColor(text,reds[j],"g","red");
}
for(j=0;j<greens.length;j++)
{
text=changeColor(text,greens[j],"g","green");
}
codeArray[i].innerHTML=text;
}
}
function changeColor(text,str,gi,color)
{
tt=new RegExp(str, gi);
text=text.replace(tt,"<B><font color="+color+">"+str+"</font></B>");
return text;
}
function filterComment(str)
{
var i=0;
while((i=str.indexOf("//",i))!=-1)
{
str=str.substring(0,i)+"<font color=green>"
+str.substring(i,str.indexOf("<br>",i))
+"</font>"+str.substring(str.indexOf("<br>",i));
i=str.indexOf("<br>",i);
}
while((i=str.indexOf("/*",i))!=-1)
{
str=str.substring(0,i)
+"<font color=green>"
+str.substring(i,str.indexOf("*/",i)+2)
+"</font>"+str.substring(str.indexOf("*/",i)+2);
i=str.indexOf("*/",i);
}
return str;
}
function filterString(str)
{
var i=0;
while((i=str.indexOf(""",i))!=-1)
{
str=str.substring(0,i+1)
+"<font color=#FF00FF>"
+str.substring(i+1,str.indexOf(""",i+1))
+"</font>"+str.substring(str.indexOf(""",i+1));
i=str.indexOf(""",i+1)+1;
}
return str;
}
onload=showCode;
</script>
<style>
pre.code
{
border: 1px dotted;
border-color:green;
background-color: white;
padding: 15px;
margin: 10px 10px;
color: black;
font-size:10pt;
width=60%;
}
</style>
<pre class=code
id='code'
name='code'
>
/*
* Created on 2005-4-14
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.tiantian;
import java.util.Random;
//import java.math.*;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class RandomArray {
public static double[][] GetArray(int a, int b) {
double num = 0;
Random random = new Random();
int number = random.nextInt(100);
int i = 10;
int j = 10;
double[][] a2;
if ((a != 0) && (b != 0))
a2 = new double[a][b];
else
a2 = new double[1][1];
for (i = 0; i < a2.length; i++)
for (j = 0; j < a2[i].length; j++) {
num = random.nextDouble();
a2[i][j] = num;
}
return a2;
}
public static void main(String[] args) {
//Random random = new Random();
//double num = random.nextDouble();
//System.out.println(number);
double[][] a = RandomArray.GetArray(10, 10);
for (int i = 0; i < a.length; i++)
for (int j = 0; j < a[i].length; j++) {
System.out.println(a[i][j]);
}
}
}