Method/functions In JAVA:

In Java A method is a block of code which only runs when it is called. You can pass data, known as parameters, into a method.

public class tut5 {
    static int sum(int x, int y){
        int c = x+y;
        return c;
    // method overloading...
    static int sum(int x, int y, int z){
        return x+y+z;
    static float sum(float a, float b){
        return a+b;
    public static void main(String[] args) {
        System.out.println(sum(2, 4)); // int
        System.out.println(sum(2, 3, 4)); // int
        System.out.println(sum(23.07f, 30.06f)); // float

1 Comment

  • […] thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently. […]

Leave a Reply

For News Subscribe Us!

Can curiosity may end shameless explained. True high on said mr on come. An do mr design at little myself wholly entire though. Attended of on stronger or mr pleasure.

You have been successfully Subscribed! Ops! Something went wrong, please try again.

© 2022 Code With AM