Tuesday, September 1, 2015

Methods in java

As we explained , we need a method called "main " so the java compiler starts executing the program. From this approach , what are methods ?
A Java method is a collection of statements that are grouped together to perform an operation.
Some methods has a return type and other methods don't and we call that "void".
such as that method main.
Note this
Java is case sensitive—uppercase and lowercase letters are distinct—so value and

Value are different (but both valid) identifiers.

public static void main(String[] args){
}
That's the method called main. Before its name, there's "public static void" .
is the starting point of every Java application. The parentheses after the identifier main indicate

that it’s a program building block called a method.
 
 Java class declarations normally contain one or more methods. For a Java application, one of the methods must be called

main and must be defined . otherwise, the Java Virtual Machine (JVM)


will not execute the application .
Methods perform tasks and can return information when they complete their tasks.
 
 
Keyword void indicates that this method will not return any information.



Later, we’ll see how a method can return information. For now, simply mimic
 
main’s first line in your Java applications. In line 7, the String[] args in parentheses is a

required part of the method main’s declaration we call that an array which will be explained next.
It really hasn't to be written this way.
that "args" can be replaced with any valid name of an array which we will explain.
thank you and good luck .

1 comment:

  1. I like how you explain things and only do a little at a time to help understand it better . Nice job !!!

    ReplyDelete