how to pass a variable in method in java and modify inside the variable
121
I always thought Java uses pass-by-reference. However, I've seen a couple of blog posts (for example, ) that claim that it isn't (the blog post says that Java uses pass-by-value). I don't think I understand the distinction they're making. What is the explanation?
129
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
31080
Are PHP variables passed by value or by reference?
15435
I fear this is probably a bit of a dummy question, but it has me pretty stumped.  I'm looking for the simplest way possible to pass a method of an object into a procedure, so that the procedure can call the object's method (e.g. after a timeout, or maybe in a different thread).  So basically I want to:   Capture a reference to an object's method. Pass that reference to a procedure. Using that reference, call the object's method from the procedure.   I figure I could achieve the same effect using interfaces, but I thought there was another way, since this "procedure of object" type declaration exists.  The following doesn't work, but might it help explain where I'm confused...?  interface    TCallbackMethod = procedure of object;    TCallbackObject = class     procedure CallbackMethodImpl;     procedure SetupCallback;   end;  implementation  procedure CallbackTheCallback(const callbackMethod: TCallbackMethod); begin   callbackMethod(); end;  procedure TCallbackObject.CallbackMethodImpl; begin   // Do whatever. end;  procedure TCallbackObject.SetupCallback; begin   // following line doesn't compile - it fails with "E2036 Variable required"   CallbackTheCallback(@self.CallbackMethodImpl); end;   (Once the question is answered I'll remove the above code unless it aids the explanation somehow.)
48999
What is the way to refer index variable inside looping ?  The code below results in error:     Failed to save undefined: expecting a positive integer, found 'indx'   at column 10 of expression: v.labels[indx]: Source       &lt;aura:iteration var="item" items="{!v.items}" indexVar="indx"&gt;         &lt;li&gt;             &lt;label class="card-detail-label"&gt;{!v.labels[indx]}&lt;/label&gt;             &lt;span class="card-detail-value"&gt;{!item}&lt;/span&gt;           &lt;/li&gt;     &lt;/aura:iteration&gt;
4013
If I have two variables:  Object obj; String methodName = "getName";   Without knowing the class of obj, how can I call the method identified by methodName on it?  The method being called has no parameters, and a String return value. It's a getter for a Java bean.
112174
There's some code in our project that looks a bit like this:  Private Sub Method1()     Call InnerMethod End Sub  Private Sub Method2()     InnerMethod End Sub  Private Sub InnerMethod()     '' stuff End Sub   What's the advantage of doing Method1 over Method2?
37233
Let me use the following example to explain my question: public string ExampleFunction(string Variable) {     return something; }  string WhatIsMyName = &quot;Hello World&quot;; string Hello = ExampleFunction(WhatIsMyName);  When I pass the variable WhatIsMyName to the ExampleFunction, I want to be able to get a string of the original variable's name. Perhaps something like: Variable.OriginalName.ToString()  Is there any way to do this?
24218
Is this functionality going to be put into a later Java version?  Can someone explain why I can't do this, as in, the technical way Java's switch statement works?
104469
Is there a way to pass a call back function in a Java method?  The behavior I'm trying to mimic is a .Net Delegate being passed to a function.  I've seen people suggesting creating a separate object but that seems overkill, however I am aware that sometimes overkill is the only way to do things.
18490
Can someone provide a simple explanation of methods vs. functions in OOP context?
45950
I'm writing a script and I would like to pass the results from bc into a variable. I've declared 2 variables (var1 and var2) and have given them values.  In my script I want to pass the results from bc into another variable say var3 so that I can work with var3 for other calculations.  So far I have been able write the result to a file which is not what I'm looking for and also I've been able to echo the result in the terminal but I just want to pass the result to a variable at moment so that I can work with that variable.  echo "scale=2;$var1/var2" | bc
29728
In other words, can I do something like  for() {     for {        for {        }     } }   Except N times? In other words, when the method creating the loops is called, it is given some parameter N, and the method would then create N of these loops nested one in another?  Of course, the idea is that there should be an "easy" or "the usual" way of doing it. I already have an idea for a very complicated one.
5691
Is there a better way of getting this result? This function fails if num has more digits than digits, and I feel like it should be in the library somewhere (like Integer.toString(x,"%3d") or something)  static String intToString(int num, int digits) {     StringBuffer s = new StringBuffer(digits);     int zeroes = digits - (int) (Math.log(num) / Math.log(10)) - 1;      for (int i = 0; i &lt; zeroes; i++) {         s.append(0);     }     return s.append(num).toString(); }
37713
I am trying to create a MATLAB class with a member variable that's being updated as a result of a method invocation, but when I try to change the property within the class it (apperently, from what I understood from MATLAB's memory management) creates a copy of the object and then modifies it, leaving the original object's property untouched.  classdef testprop       properties           numRequests=0;       end       methods           function Request(this, val)               disp(val);               this.numRequests=this.numRequests+1;           end       end   end     .  &gt;&gt; a=testprop; &gt;&gt; a.Request(9); &gt;&gt; a.Request(5);   &gt;&gt; a.numRequests    ans = 0
118537
In C#, if you want a method to have an indeterminate number of parameters, you can make the final parameter in the method signature a params so that the method parameter looks like an array but allows everyone using the method to pass as many parameters of that type as the caller wants.  I'm fairly sure Java supports similar behaviour, but I cant find out how to do it.
53456
What is the difference between:  some_list1 = [] some_list1.append("something")   and  some_list2 = [] some_list2 += ["something"]