Posts

Showing posts with the label Static method

static method void return type primitive parameter

static method with void return type with primitive parameter: Lets describe what is the mean of static method whose return type is primitive and it has primitive parameter. void return type i.e. it does not returns any type of value and primitive parameter means it has a parameter like int, char, float etc.... static method means it can be called with class name i.e. there is no need to create the object of the class for calling this method . A program for this tutorial is given below- class Sm {  static void abc(int a,boolean b)   {     System.out.println("inside static method of abc of class Sm");   } public static void main(String args[])   {    int a=20;    boolean c=true;    Sm.abc(a,c);   } } Explanation: In this program we can also call abc() method directly without class name because within the same class we can call static method with or without class name. For Example: class Sm1 {  sta...

static method void return type with zero parameter

Static method with Void Return type with zero parameter in java : This tutorial is provided to understand the mean of void return type with zero parameter.In java, there are three types of methods namely- 1)  Void return type. 2)  Primitive return type 3) reference  return type.  Void return type means a method which returns no value and zero parameter means no parameter is passed within the method. Let's demonstrate void return type method with zero parameter in java. Program for this tutorial is given below- class Sm1 { static void abc() {        System.out.println("inside static method of abc");  }  } class  Test { public static void main(String[] args)  { Sm1.abc(); } } Explanation: abc() is a staic method in this program i.e. it can be called without creating object of this class. So we called it with class name i.e. Sm1. abc() is not returning any type of value so its...