public class GreetingR
1: //GreetingR.java
2: //Note the use of the Java keyword "this" in this version.
3:
4: public class GreetingR
5: {
6: private String text;
7:
8: public GreetingR()
9: {
10: text = "Nothing to say";
11: }
12:
13: public GreetingR
14: (
15: String text //in
16: )
17: {
18: this.text = text;
19: }
20:
21: public String getText()
22: {
23: return text;
24: }
25:
26: public void setText
27: (
28: String text //in
29: )
30: {
31: this.text = text;
32: }
33:
34: /*
35: public static void main(String[] args)
36: {
37: GreetingR myGreeting = new GreetingR();
38: System.out.println(myGreeting.getText());
39: GreetingR yourGreeting = new GreetingR("Hello");
40: System.out.println(yourGreeting.getText());
41: myGreeting.setText("Hi there!");
42: System.out.println(myGreeting.getText());
43: }
44: */
45: }
46: