-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
32 lines (22 loc) · 1007 Bytes
/
Main.java
File metadata and controls
32 lines (22 loc) · 1007 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
28
29
30
31
32
import java.util.Scanner;
//Overloading methods in Java refers to creating multiple methods by the same name, that take different types / ammounts of parameters.
//Together the return type, name, and parameters create a unique method signiture.
/*Three places where variables can go: after Main, a class variable.
After static void main, a local variable, or in any other method under main, also local to its method.
*/
public class Main {
public static void main(String[] args){
//Practice with methods
Scanner scanner = new Scanner(System.in);
System.out.print("Enter your name: ");
String name = scanner.next();
happyBirthday(name);
scanner.close();
}
static void happyBirthday(String name){
System.out.print("\nHappy birthday to you,\n");
System.out.print("Happy birthday to you,\n");
System.out.print("Happy birthday dear " + name +",\n");
System.out.print("Happy birthday to you!!!\n\n\n");
}
}