In this post I'm going to show you how to correctly declare a Java method. Java method is the place where we going to tell the program what should program must do. As I told you in my previous post, we have to declare Java methods inside the Java class.
Actually Java methods are the things that runs when we run the Java program.
Following code shows how Java method place inside the class and how Java method is declare correctly.
You can see some new Java keywords in above code, let me explain those keywords.
public is an access modifier ( access modifier is access controller to the Java method you will find more details about access modifiers in upcoming posts).
static is an non-access modifier (you will find more details about non-access modifiers in upcoming posts).
void is the return type (you will find more details about return types in upcoming posts).
main is the method name.
(String args[]) is the parameter of the method.
{ } shows the scope of the method.(Running code must be inside the method scope).
For next 10-15 posts we are going to use this main method to do our coding. After that we will create other methods rather than main method.
No comments:
Post a Comment