Monday, December 5, 2022

How to create method and call in Java | Java Programing Tutorial for Beginners

 In this java tutorial we will learn about how to create method and call method with example step by step . If you have any doubts  you can watch java tutorial  which is in English and Hindi languages.

    Create method and call in Java in English Video Tutorial

    Create method and call in Java in Hindi Video Tutorial

For more video click on this link  @amazingcodingtechworld
Lets create class and and check mark on public static void so it will create main method, where we  will call .

public class JavaMethod {

public static void main(String[] args) {
// TODO Auto-generated method stub


Now will  create method in side class called Java method. 

we have created myMethod and we use void since we are not returning anything and when we create method we give parenthesis() at will provide curly bracket .   Inside out curly bracket we have out logic in this case we want to print " method"
now to call this , in the main method we have to create instance of our class.  so syntax is name of our class then provide variable name which is instance of our class and =  new and provide class name. Now we have instance of our class now we can use it. if we type that instance and use dot operator we can access method inside our class and we can see out put as described in picture. This is how you use to create and call non static method. If you want to create static method you simple type name of method in main class. 

java switch statement | Java Tutorial For Beginners

 Switch statement is alternative and more cleaner way to write code if we have more than two options. we can use else if, this is better way...