Assign Equality to Elements Directly out of Array Java

In python if you have a tuple or list of the form, myTuple = (a,b,c), you can assign equality to different variables by saying var1, var2, var3 = myTuple. I was wondering if there was any way to do an analogous thing in Java.

1 answer

  • answered 2022-01-23 03:21 Gurkirat Singh Guliani

    In java , you cannot assign different variables values simultaneaously like this

    var1, var2, var3 = myTuple.

    You will have to do somthing like this :

    int val[] = {1,2,3,4};
                int a,b,c,d=0;
            
                    a = val[0];
                    b = val[1];
                    c = val[2];
                    d = val[3];
    

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum