下面是我写的函数,出现几个问题
1,如果total[0][0]=88 这样的话,程序会出错,也就是说一个数组里面不能即放字符又放数字
2,怎么写一个包含多个参数的函数?
<%
String total[][]=new String[3][2];
//int str[] = new int[20];
total[0][0]="88";
total[1][0]="200";
total[2][0]="800";total[0][1]="中文";
total[1][1]="英文";
total[2][1]="数组";
for(int i=0;i<total.length;i++)
{
out.print(total[i][1]);
out.print("<br>");
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body>
<%=hello()%>
</body>
</html>
以上是调用函数的例子,下面是所调用的函数<%!
String hello(){
return("<hr>");
}
%>
1,如果total[0][0]=88 这样的话,程序会出错,也就是说一个数组里面不能即放字符又放数字
2,怎么写一个包含多个参数的函数?
<%
String total[][]=new String[3][2];
//int str[] = new int[20];
total[0][0]="88";
total[1][0]="200";
total[2][0]="800";total[0][1]="中文";
total[1][1]="英文";
total[2][1]="数组";
for(int i=0;i<total.length;i++)
{
out.print(total[i][1]);
out.print("<br>");
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body>
<%=hello()%>
</body>
</html>
以上是调用函数的例子,下面是所调用的函数<%!
String hello(){
return("<hr>");
}
%>
不明白什么意思。是不是要下面的函数。<%!
String hello(String str1,String str2){
return("<hr>"+str1+"<hr>"+str2);
}
%>
Integer,Float,Double,String等
先生成一个Hashtable 向上面的你可以这么写
Hashtable hash=new Hashtable();
hash.put("语文",new Integer(88));
hash.put("数学",new Float(88.9));
hash.put("英语",new Double(66.55));
//你可以用接口方式把元素一个一个取出来
Enumeration en=hash.elements();
while(en.hasMoreElements())
{
out.println(en.nextElement());
}
//也可以直接用get
out.println(hash.get("语文"));
out.println(hash.get("数学"));