File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Frame & Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Frame & Applet" Watch "Frame & Applet" New topic
Author

Frame & Applet

Thiru Thangavelu
Ranch Hand

Joined: Aug 29, 2001
Posts: 219
Why "hello world" is not printed when the constructor is present?

[ June 12, 2002: Message edited by: Thiru Thangavelu ]
[ June 12, 2002: Message edited by: Thiru Thangavelu ]

Thanks,<br />Thiru<br />[SCJP,SCWCD,SCBCD]
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Shouldn't that be text=s;


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
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
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
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
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();
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Frame & Applet