-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtutorial_27.java
More file actions
27 lines (25 loc) · 824 Bytes
/
tutorial_27.java
File metadata and controls
27 lines (25 loc) · 824 Bytes
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
class Driver {
//
public static void main(String[] args) {
System.out.println( greeting() );
System.out.println( greeting("Jeremy") );
System.out.println( greeting("Jeremy", "England") );
}
//
static String greeting() {
return greeting("Person", "");
}
//
static String greeting(String f) {
return greeting(f, "");
}
// added a ternary operator here as per request to get rid of the extra space when only putting a first name.
static String greeting(String f, String l) {
return (
"--------------------------------\n" +
"Hello, " + f + (l.equals("") ? "": " ") + l + ". Welcome to my app.\n" +
"--------------------------------"
);
}
//
}