Java examples for Object Oriented Design:Java Bean
Methods beginning with set and get are termed as setter and getter methods.
public static void main(...) is used from within a public class to denote the entry point of a Java program.
public class Main { /* The main method begins in this class */ public static void main(String[] args) { /*from w w w . jav a 2 s. co m*/ HelloMessage hm; hm = new HelloMessage(); System.out.println(hm.getMessage()); hm.setMessage("Hello, World"); System.out.println(hm.getMessage()); } } 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(); } }