Saturday, November 5, 2022

PASSING AS A OBJECT PARAMETERS

 public class MethodPractice1 {

    static void change(int A[],int index,int value)

    {

        A[index]=value;

    }

    static void change2(int x,int value)

    {

        x=value;

    }

    public static void main(String[] args) {

        int A[]={2,4,6,8,10};

        

        change(A,2,20);

        

        for(int x:A)

        {

            System.out.println(x);

        }

        

        int x=10;

        

        change2(x,20);

        

        System.out.println("Value of primitive :"+x);

    }

    

}

No comments:

Post a Comment

CONSTRUCTURE IN PARENT CLASS

class Parent {     public Parent()     {         System.out.println("Parent Constrcutor");     }              } class Child extend...