Return Type Of Method In Java - Tutorials For Selenium WebDriver

We bring learnt METHOD IN JAVA software evolution linguistic communication together with dissimilar METHOD ACCESS MODIFIERS inwards my previous posts. Now allow me innovate yous amongst dissimilar return types of methods inwards java software evolution language. You tin go operate 2 form of render types amongst methods. 1. Void and 2. Any information types. Void way returning zilch together with when your method is returning approximately values similar Integer, String, double, etc.., You need to render return type amongst method according to returning value's information types inwards java software evolution language.
  • int, String, double etc..Data types - If method is returning whatever value together with thus yous need to render render type amongst method similar int, String, Double etc..
  • void - If method is non returning whatever value together with thus yous tin go hand void equally render type. void way method returning nothing.
Let me hand yous elementary event of int, double together with void render type.
package Test_Package1;  world cast Return_Types {   static int c;  static double d;   world static void main(String[] args) {   Mul(2,3);   Div(7,3);   System.out.println("Value of c Is "+c);   System.out.println("Value of d Is "+d);   Message();  }  //This method is returning integer value. It's render type is int.  world static int Mul(int a, int b){   c=a*b;   render c;    }   //This method is returning double value. It's render type is double.  world static double Div(double a, double b){   d=a/b;   render d;    }  //This method is returning zilch thus at that topographic point is used void render type.  world static void Message(){   System.out.println("Test Message");  } }
If yous run across inwards in a higher house example, I bring used 3 methods (Mul, Div together with Message) together with called all 3 methods inwards primary method to execute them. 
  • Method Mul is returning multiplied integer value inwards variable c thus I bring used int information type equally render type amongst Mul method. 
  • Method Div is returning sectionalisation of 2 values inwards variable d thus I bring used double information type as render type amongst Div method.
  • Method Message is returning zilch thus I need to operate void render type amongst It inwards java  software evolution language.
More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM

http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post