aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Answer :Run time error /  why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Answer :Run time error /  why?" Watch "Answer :Run time error /  why?" New topic
Author

Answer :Run time error / why?

tian Lau
Greenhorn

Joined: Jul 10, 2000
Posts: 20
import java.applet.Applet;
import java.awt.*;

public class Sample extends Applet {
private String text = "Hello World";
public void init() {
add(new Label(text));
}
public Sample (String string) {
text = string;
}
}

It is accessed form the following HTML page:

<html>
<title>Sample Applet</title>
<body>
<applet code="Sample.class" width=200 height=200></applet>
</body>
</html>

kevin jia
Ranch Hand

Joined: Jul 13, 2000
Posts: 38
Applet can't hava constructor with arguments. It can have constructor no arguments.
kevin jia
Ranch Hand

Joined: Jul 13, 2000
Posts: 38
Try the code below, maybe you can find answer.
import java.applet.Applet;
import java.awt.*;
public class Sample extends Applet {
String text;
public void init() {
add(new Label(text));
}
public Sample() {
text = "Hello cruel world!";
}
<html>
<body>
<applet code="Sample.class" width=200 height=200>
</applet>
</body>
</html>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Answer :Run time error / why?