The default constructor is needed. Otherwise, how the browser is going to pass the parameter?
SCJP2. Please Indent your code using UBB Code
Thiru Thangavelu
Ranch Hand
Joined: Aug 29, 2001
Posts: 219
posted
0
Yes, it is text = s Why do we need the default constructor since we have the string "hello world" as parameter text. I think I am missing some concept here.
Jose Botella
Ranch Hand
Joined: Jul 03, 2001
Posts: 2120
posted
0
It is not needed for setting the value of text, but in case the applet is going to be executed by a browser.
Brusk Baran
Ranch Hand
Joined: Nov 15, 2001
Posts: 132
posted
0
Applet vs Application?? I converted the applet so that it can be run as an application too. is this allowed??? import java.awt.*; import java.applet.Applet; public class TestAppletMain extends Applet { private String text = "Hello World"; public void init() { add(new Label(text)); } /* public TestAppletMain (String s) { text = s; } */ public static void main(String args []){ TestAppletMain ss = new TestAppletMain (); ss.init(); } }