METHODS
Methods: 
                Block of statement is used to perform specific task  or job is known as methods.
 Ex.
power button( )                                                                                         
{                                                                                                               
on;                                                                                                      
off;                                                                                                      
}                                                                                                               
Note: 
- Methods get executed only when it is called.
- A method can be called n number of times.
- We can not create a method inside another method.
Ex.
class P3                                                                                                        
{                                                                                                               
public static void dell( )                                                                     
 {                                                                                                              
System.out.println("Hi");                                                                 
 }                                                                                                              
public static void main(String [ ] args)                                            
{                                                                                                         
 System.out.println("Main begin");                                              
 dell( );                                     //Method calling statement            
 System.out.println("Main ends");                                              
}                                                                                                          
}                                                                                                               
Output:
Main begin                                         
Hi                                                       
Main ends
Main ends
 
0 Comments