#Doubt in question

1 messages ยท Page 1 of 1 (latest)

balmy mica
#

Is it because we are not returning anything?

trim grottoBOT
#

<@&987246399047479336> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#

It is possible that the question you are referring to does not have a return statement, which means it does not return any value. However, it is also possible that the question is asking for a specific output or behavior rather than a return value. Without more context or the specific question, it is difficult to determine the exact reason why there may be no return statement.

balmy mica
#

I was thinking 24 42

trim grottoBOT
#

In Java, primitive types such as int, float, double, boolean, etc. are passed by value.

When a primitive type is passed as an argument to a method, a copy of the value is made and assigned to the parameter variable within the method. Any changes made to the parameter variable will not affect the original value outside of the method.

For example:

public class Main {
    public static void main(String[] args) {
        int num = 10;
        System.out.println("Before: " + num);
        
        modifyValue(num);
        
        System.out.println("After: " + num);
    }
    
    public static void modifyValue(int value) {
        value = 20;
    }
}

Output:

Before: 10
After: 10

In this example, the modifyValue method takes an integer parameter value and assigns it a new value of 20. However, this change does not affect the original num variable outside of the method.

This behavior is because when a primitive type is passed by value, only a copy of its value is passed to the method. Therefore, any modifications made within the method are only applied to the local copy and do not affect the original variable.

idle rain
#

void means there is no return value, meaning that even though the parameters variables changed, x and y remain the same

#

@balmy mica did this answer your question?

stoic pecan
#

var1 and var2 are being swapped. but that does not affect x and y

pine minnow
#

If you use primitive types as parameters, u'll gonna receive the value

#

If you would use class types, u'll gonna receive a reference to that object

#

Means that in that case changes on the reference would affect the actual object given to the method