-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathExtraMethodConcepts.java
More file actions
executable file
·30 lines (25 loc) · 1.21 KB
/
ExtraMethodConcepts.java
File metadata and controls
executable file
·30 lines (25 loc) · 1.21 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
// JAVA METHODS II
public class ExtraMethodConcepts {
public static void main(String[] args) {
// Call the method to print the welcome message
printWelcomeMessage();
}
// Method that print a welcome message
public static void printWelcomeMessage() {
System.out.println("Welcome to my Java program!");
}
}
/*
- We defined a class named "Extra".
- Inside the "Main" Class we define the main method which is an entry point of the program
- We call the "PrintWelcomeMessage" method which prints a welcome message to the console.
- The "printWelcomeMessage" method is declared with a return type void, indicating that it doesn't return anything.
- The method doesn't have any parameters.
- Inside the method, we use System.out.println to print the welcome message.
*/
/*
This demonstrates how to define and call a method in Java that doesn't return anything and doesn't have any parameters.
You can use such methods for performing tasks that don't require input parameters or returning values.
*/
// YOU CAN DECLARE A FUNCTION BEFORE CALLING IT OR YOU CAN CALL THE FUNCTION BEFORE DECLARING IT. BOTH WILL WORK
// LOOK AT Main.java FILE TO SEE THE DIFFERENCE BETWEEN Extra.java and Main.java....