-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathGreeter.java
More file actions
41 lines (37 loc) · 1.18 KB
/
Greeter.java
File metadata and controls
41 lines (37 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* The first example class for CCPS 109. An object constructed from this
* class has two capabilities, the ability to output a greeting, and the
* ability to output a bye message. The objects contain no data fields or
* other internal state.
* @author Ilkka Kokkarinen
*/
public class Greeter {
/**
* Outputs a simple greeting to the console.
*/
public void greet() {
System.out.println("Hello, world!");
}
/**
* Outputs a simple goodbye message to the console.
*/
public void bye() {
System.out.println("See you later!");
}
/**
* Having the main method allows this class to execute as a
* standalone application. When using BlueJ, you don't need
* a main method in your class to try out its objects and
* their methods interactively. Most classes are not intended
* to be standalone applications, but to be used as parts of
* some larger program.
*/
public static void main(String[] args) {
// Declare and create a new Greeter object.
Greeter g = new Greeter();
// Now we can call its methods.
g.greet();
g.bye();
g.greet();
}
}