TOPIC 3 : JAVA LANGUAGE
modifier 3.5 METHOD
(METHOD DEFINITION and METHOD CALL for type 1 and Type 2)
Method Definition Method Calls
General Format of Method Definition General Format of Method Calls
public static / static returnType methodName classname. methodName (arguments);
(parameters) { OR
// method body methodName (arguments);
}
Type 1 : A method definition which return Type 1 :
no value, receive no parameters receive no value, pass no arguments
public static void showWelcome( ) {
System.out.print (“Welcome to Java”); showWelcome ( ) ;
}
Type 2 : A method definition which Type 2 : receive no value, pass
return no value, receive parameters arguments
static void sayHello(String name) {
System.out.print (“Hello” + name); sayHello (name) ;
}
modifier 3.5 METHOD
(METHOD DEFINITION and METHOD CALL for type 1 and Type 2)
Method Definition Method Calls
General Format of Method Definition General Format of Method Calls
public static / static returnType methodName classname. methodName (arguments);
(parameters) { OR
// method body methodName (arguments);
}
Type 1 : A method definition which return Type 1 :
no value, receive no parameters receive no value, pass no arguments
public static void showWelcome( ) {
System.out.print (“Welcome to Java”); showWelcome ( ) ;
}
Type 2 : A method definition which Type 2 : receive no value, pass
return no value, receive parameters arguments
static void sayHello(String name) {
System.out.print (“Hello” + name); sayHello (name) ;
}