this is the test code I am using to understand how java handles object memory.  public class TestCode {    public static void main(String[] args) {     TestCode obj = new TestCode();      CustomClass cs1 = new CustomClass(5);     obj.updateExistingObj(cs1);     System.out.println(cs1.val);      CustomClass cs2 = new CustomClass(5);     obj.instantiateExistingObj(cs2);     System.out.println(cs2.val);      CustomClass cs3 = null;     obj.updateNullObj(cs3);     System.out.println(cs3.val);   }    void updateExistingObj(CustomClass cs1) {     cs1.val = 9;   }    void instantiateExistingObj(CustomClass cs2) {     cs2 = new CustomClass(9);   }    void updateNullObj(CustomClass cs3) {     cs3 = new CustomClass(9);   } }  class CustomClass {   int val;   CustomClass next;   CustomClass(int x) { val = x; } }   The output of the first syso where I am printing cs1.val I am getting expected value which is 9.  The output of the second syso where I am printing cs2.val I am getting 5 as output instead of 9.  The output of the third syso where I am printing cs3.val I am getting a null pointer exception.   Can anybody help me understand what is happening here under the hood? How exactly java handles the memory location when we pass an object as a function parameter? Thanks for helping!!
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?
How to run the Ubuntu ISO live image from Windows without USB or DVD?  This is a self answered question. Can the system leave a deletion reason when it deletes a question? they were question banned; it turned out it (in part) it was because of deleted questions.   was deleted by the Community user.  I'm aware it will delete old posts that have a negative score, but for a minute or two, I was really puzzled as to why it was unilaterally deleted without some notation left.  Can we have the Community user leave a notation in a post's history as to why the post was deleted?    Something like the following would suffice:     Post deleted automatically due to having negative votes and no activity for three months Google page title not matching html  tag Is there a limit to Rule 0? Rule Zero: All other rules can be changed by the GM.   I appreciate that there is a massive amount of work that goes into being a GM and the last thing that any GM wants or deserves is to have his players constantly questioning everything they do. However, a group I am currently playing with has been having a huge problem with a GM who has been using rule 0 to deny virtually every skill check and give all his custom enemies powers that have either no save or unbeatable DCs. Then, whenever he realizes he has made the fight unwinnable he brings in one of his level 60+ GMPCs to instantly win the fight, making us feel even more helpless.  We try to hold our tongues and not be the dreaded Rules Lawyer, but he keeps pulling out stuff so ridiculous that we have to question it… and every time we do we find that he is either misunderstanding or completely disregarding the rules. When this happens he always jumps immediately to rule 0. He probably cited rule 0 around 6 times in our last session (and we only had one combat encounter). How can I play mp3 files or videos? Computing convex hull of points using shapely Detecting unused packages in LaTeX document I have quite a bad habit of copy-and-pasting my packages from one LaTeX document to another. Is there any way we can detect unused packages (i.e. \usepackage commands) so that they can be removed from the LaTeX document? Vertically align text next to an image? Calculation of subgroups of $(Z_{12}, +)$ How calculate all subgroups of $(Z_{12}, +)$?  I know that the order of subgroups divide the order of the group, but there is such a smart way to calculate the subgroups of order 6? Let $G$ be abelian, $H$ and $K$ subgroups of orders $n$, $m$. Then G has subgroup of order $\operatorname{lcm}(n,m)$. I'm actually at the cemetery at White Orchard. There is a white question mark and some little red arrows.  What are this little red arrows?  Do they point to something dangerous? Which OpenType Math fonts are available? Can WMS be used to get a local copy of raster data? Bizarre spacing with 4 $\star$s Is there a way (eg. a binary hack into Finder) to stop it from creating .DS-Stores on LOCAL Volumes?   I am using Leopard, therefore these don't work:    (requires Lion)  (requires Snow Leopard)   Also,  slows down my computer. I'm using leaflet to display a map.  I have a control section that I'd like to be open by default, but I can't find a way to do it through the . Is there a way to do this? Why do we use $x - y$ rather than $x + y$ in the definition of the convolution? Is it just convention? (If we are thinking of convolutions as weighted averages, for instance against "good kernels," it should make no difference.)  Why $(f * g) (x) = \int f(y) g(x - y) dy$ rather than $(f * g) (x) = \int f(y) g(x + y) dy$?  Edit: I'm finding it really hard to choose a best answer. There are at least three very good ones here. Can $\frac{\sqrt{3}}{\sin20^{\circ}}-\frac{1}{\cos20^{\circ}}$ have two values? How does Natural Selection shape Genetic Variation? Background  Importance of the additive genetic variance  As stated , the fundamental theorem of Natural Selection (NS) by Fisher says:     The rate of increase in the mean fitness of any organism at any time ascribable to NS acting through changes in gene frequencies is exactly equal to its genetic variance in fitness at that time.   NS reduces the additive genetic variance  On the other hand, NS reduces additive genetic variance (discussion about the origin of this knowledge can be found ). The genetic variance of a population for multiple traits is best described by the G-matrix ( is a post on the subject).  What is a G-matrix  A G-matrix is a matrix where additive genetic variance of trait $i$ can be found at position $m_{ii}$. In other words, the diagonal contains the additive genetic variance for all traits. The other positions $m_{ij}$, where $i≠j$ contains the additive genetic covariance between the traits $i$ and $j$.  Question  How can one model how the G-matrix changes over time because of selection (assuming no mutation)? Why are PATH variables different when running via sudo and su? On my fedora VM, when running with my user account I have /usr/local/bin in my path:  [justin@justin-fedora12 ~]$ env | grep PATH  PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/justin/bin   And likewise when running su:  [justin@justin-fedora12 ~]$ su - Password:  [root@justin-fedora12 justin]# env | grep PATH PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/justin/bin   However, when running via sudo, this directory is not in the path:  [root@justin-fedora12 justin]# exit [justin@justin-fedora12 ~]$ sudo bash [root@justin-fedora12 ~]# env | grep PATH PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/sbin:/bin:/usr/sbin:/usr/bin   Why would the path be different when running via sudo?