Method / Function Part 1

PHOTO EMBED

Mon Apr 19 2021 18:22:50 GMT+0000 (Coordinated Universal Time)

Saved by @ahmedqgqgq #java

public class MyName {
    public static void main(String[] args) {// Method/function.
        System.out.println("Ahmed");
        System.out.println("Ali");
        System.out.println("Mohammed");
        System.out.println("Belal");
    }
}
public class MyName {
    public static void main(String[] args) {// Method/function.
        System.out.println("Ahmed");
        System.out.println("Ali");
        System.out.println("Mohammed");
        System.out.println("Belal");
        System.out.println("Ahmed");
        System.out.println("Ali");
        System.out.println("Mohammed");
        System.out.println("Belal");
    }
}
public class MyName {
    // Return value type:voidنوع القيمة الراجعة
    public static void fun() {
        System.out.println("Ahmed");
        System.out.println("Ali");
        System.out.println("Mohammed");
        System.out.println("Belal");
    }
    public static void main(String[] args) {// Method/function.
        // invoke,callاستدعاء,دعوه
        fun();
    }
}
public class MyName {
    public static void fun() {
        System.out.println("Ahmed");
        System.out.println("Ali");
        System.out.println("Mohammed");
        System.out.println("Belal");
    }
    public static void main(String[] args) {
        fun();
        fun();
    }
}
public class MyName {
    public static void main(String[] args) {
        fun();
        fun();
    }
    public static void fun() {
        System.out.println("Ahmed");
        System.out.println("Ali");
        System.out.println("Mohammed");
        System.out.println("Belal");
    }
}
import java.util.Scanner;
public class MyName {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n1, n2;
        System.out.println("Enter number1:");
        n1 = input.nextInt();
        System.out.println("Enter number2:");
        n2 = input.nextInt();
        int sum = n1 + n2;
        System.out.println("the sum==" + sum);
    }
}
import java.util.Scanner;
public class MyName {
    static int SumTwoNumbers(int n1, int n2) {
        int sum = n1 + n2;
        return sum;
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n1, n2;
        System.out.println("Enter number1:");
        n1 = input.nextInt();
        System.out.println("Enter number2:");
        n2 = input.nextInt();
        System.out.println("the sum==" + SumTwoNumbers(n1, n2));
    }
}
import java.util.Scanner;
public class MyName {
    static int SumTwoNumbers(int n1, int n2) {
        int sum = n1 + n2;
        return sum;
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("the sum==" + SumTwoNumbers(50, 60));
    }
}
import java.util.Scanner;
public class MyName {
    static int SumTwoNumbers(int n1, int n2) {
        return n1 + n2;
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("the sum==" + SumTwoNumbers(50, 60));
        System.out.println("the sum==" + SumTwoNumbers(200, 50));
    }
}
import java.util.Scanner;
public class MyName {
    static int SumTwoNumbers(int n1, int n2) {
        return n1 + n2;
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("the sum==" + SumTwoNumbers(50, 60));
        System.out.println("the sum==" + SumTwoNumbers(200, 50));
    }
}
import java.util.Scanner;
public class MyName {
    static int SumTwoNumbers(int n1, int n2) {
        System.out.println("sum:");
        return n1 + n2;
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int s = SumTwoNumbers(5, 5);
        s = s + 2;
        System.out.println("sum==" + s);
    }
}
import java.util.Scanner;
public class MyName {
    static int SumTwoNumbers(int n1, int n2) {
        System.out.println("sum:");
        return n1 + n2;
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int s = SumTwoNumbers(5, 5);
        s = s + 2;
        System.out.println("sum==" + s);
    }
}
import java.util.Scanner;
public class MyName {
    static voidSumTwoNumbers(int n1, int n2) {
        System.out.println("sum=="+(n1+n2));
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int s = SumTwoNumbers(5, 5);//error
        s = s + 2;
        System.out.println("sum==" + s);
    }
}
import java.util.Scanner;
public class MyName {
    static void SumTwoNumbers(int n1, int n2) {
        System.out.println("sum==" + (n1 + n2));
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        SumTwoNumbers(5, 5);
    }
}
import java.util.Scanner;
public class MyName {
    static void SumTwoNumbers(int n1, int n2) {
        if (n1 == 0 && n2 == 0) {
            return;
        }
        System.out.println("sum==" + (n1 + n2));
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        SumTwoNumbers(5, 5);
    }
}





content_copyCOPY