Java Reference
In-Depth Information
/* An object of this class will hold the message. */
class HelloMessage {
private String message = "";
public HelloMessage() {
this.message = "Default Message";
}
public void setMessage (String m) {
this.message = m;
}
public String getMessage () {
return this.message.toUpperCase();
}
}
/* The main program begins in this class */
public class HelloWorld {
public static void main(String[] args) {
HelloMessage hm;
hm = new HelloMessage();
System.out.println(hm.getMessage());
hm.setMessage("Hello, World");
System.out.println(hm.getMessage());
}
}
You can find the code in Listing 1-1 as part of our example download for the topic.
It's in the file HelloWorld.java , and you'll find that file within the NetBeans
Search WWH ::




Custom Search