传值调用~,编译通过,可执行时出错
代码如下:
<applet code=E2.class height=200 width=300>
<Param name="girl" value="160">
<Param name="boy" value="175">
</applet>
import java.awt.*;
import java.applet.*;
public class E2 extends Applet
{
int x=8,y=9;
public void init()
{
String s1=getParameter("girl");
String s2=getParameter("boy");
x=Integer.parseInt("s1");
y=Integer.parseInt("s2");
}
public void paint(Graphics g)
{
g.drawString("x="+x+","+"y="+y,20,30);
}
}
打开浏览器出错提示为:Exception:java.lang.NumberFormatException:s1
高手指教~