Java Class Methods in Hindi

Java

Java Class Methods in HindiClass Methods in Java – Class Methods Ek Tarah Ka Java Class Function Hi Hota Hai Jaise Ki Python Or PHP Etc Me Class Function Ka Istemal Kiya Jata Hai Usi Tarah Se Java Me Class Methods Ka Istemal Kiya Jata Hai |

Methods Ko Ham Simple Way Me Kahe To Ye Java Me Function Ki Tarah Kaam Karta Hai |

Java Class Methods in Hindi

Java Class Function in Hindi ko ham Isliye Istemal Karte hai Taki Hame Ek Hi Code Ko Bar Bar Likhna Na Pade isliye Java programming me ham Method ko banante hai |

Function Kiya Hai ? :- Function Line of code ya sub program hota hai inka ek group hota hai chota program ka us program me kitni bhi line ho sakti hai or inka aapna ek name & Features hota Hai Or Function ko Aap Program me Kahi bhi Call Ya Dobara Istemal kar Sakte Hai |

Read Also :- Arrays & Multidimensional Arrays

Function ko Kyo Istemal Karte hai? :- Jab Ham koi code likhte hai to wo code main ke under hi execute hota hai | Lekin Jab koi program bahut Bada Ho Jaye Or koi code of line bar bar repeat ho rhi ho to ham function Bana Sakte hai isse program aashan ho jata hai |

JAVA Cl ass methods se Hamara matlab JAVA ki statements ke ek aise collection hai jinko hum ek group me execute krte hain koi na koi operation perform krne ke liye. Jaise JAVA me  System.out.println() method execute hone pe iss method ki sari statements ka output hame console (monitor screen) pe display ho jata hai.

Syntax:

Method defination me do cheezen zaruri hoti hain, ek mathod header aur doosra mathod body.  Method header me modifier, return type, method name aur parameters ki list hoti hai. Method body ko hum curly braces ({}) se enclose krte hain jisme sari method statements hoti hain. Neeche diye gye method defination ke syntax ko dhyan se padhe aur smjhe:-

Also Read – Java Strings

public class Main {
  static void methodName() {
 	// body	
  }
}

Example:

public class Main {
  static void methodName() {
 	System.out.println("This Is Method -> methodName ");	
  }
}

Aap Upper Program me Dekh Sakte Hai, Hamne Ek Method (methodName) Create Kar Liya Hai, Ab Ham Ise Main Ke Under Direct Call Kar Sakte Hai |

Example 2:

public class Main {
  static void methodName() {
    System.out.println"This Is Method -> methodName ");
  }
  public static void main(String[] args){
    methodName();   // calling 
  }
}

Aap Dekh Sakte Hai, Hamne Method Create Karne Ke Bad Main Ke Under methodName() Ko Call Kar Diya Hai |

Output:

This Is Method -> methodName 

Static Vs Public In Java In Hindi

Aap Ye Soch Rahe Honge Ki, Kahi Par Public Or Kahi Par Static Istemal Kar Rahe Hai, To Me Aapko Bata tu Agar Hame Class Ke Under Method Create Karna Hai, Or Use Main ke Under Bina Object Create Kiye Call Karna Hai, To Ham Waha Par Static Ka Istemal karte Hai |

Also Read – Java Classes/Objects

And Aap Class Ke Object Ko Create Karne Ke Bad Call Karna Chahte Hai To, Public Ka Istemal Kar Sakte Hai, Public Me Bina Object Create Kiye Aap method Ko Call Nhi Kar Sakte Hai |

Example 3:

public class Main {
  // static method
  static void Static_myMethod() {
    System.out.println("This is Static Method");
  }
  
  // public method
  public void Public_myMethod() {
    System.out.println("This is Public Method");
  }
  
  // Main Method
  public static void main(String[] args) {
    // static method calling 
    Static_myMethod();
    
    // public method calling
    Main obj = new Main();  // create object
    obj.Public_myMethod();  // Calling public Method 
  }
}

Aap Upper Program Ko Dekh Sakte Hai, Hamne Main Class Create Ki Or Uske Bad Hamne 2 Method Create Kiye Ek Static And Public Fir Hamne main Ke Under Dono Ko Call Kiya Hai |

Output:

This is Static Method
This is Public Method

Dosto mujhe ummed hai ki aap Methods in Java in Hindi  ko acchi tarah se samanj gye honge agar aap ko ye post acchi lage to mere is website ko jarur follow kre |

Leave a Reply

Your email address will not be published.