[after edit 1] I have seen the other answers here in SO, and from looking at my code, I find that I am adhering to the principle of Java's pass-by-value-of-reference. But still my array is not getting sorted. Please can someone point out any errors I am making in my code?  [after edit 2] Found the problem. It was nothing to do with array passing. In my merge method, it should be if (end-start&lt;=0) not the other way round!   I am trying to implement mergesort. However, I am unable to display values of my array and am unsure of how to pass my arrays in Java such that the original array can be modified.   How can I modify my current code to display the values of the sorted array?  I , but doesnt this mean that the original array gets modified?  CODE:  I am calling mergesort method from my main method.  public static void main(String[] args) {         int[] qn = {10,22,33,4,5,6,1};         qn= mergesort(qn,0,qn.length-1);         for (int i=0;i&lt;qn.length;i++){ //print to see values if sorted/not                System.out.print(qn[i]+ " ");         }      }  public static int[] mergesort(int[] arr,int start,int end){             int mid = (end+start)/2;         if (end - start&lt;=0){             return arr;         }             else if (end-start&gt;=1){                  arr=mergesort(arr,start,mid);             arr=mergesort(arr,mid+1,end);          }             arr=merge(arr,start,end);             for (int i=0;i&lt;arr.length;i++){                    System.out.print(arr[i]+ " ");             }             System.out.println();             return arr;     }      public static int[] merge(int[] arr,int start,int end){             int mid= (start+end)/2;         if(start-end&lt;=0){             return arr;         }          int a= start; int b = mid+1;         while (a&lt;=mid &amp;&amp; b &lt;=end){             if (arr[b]&lt;arr[a]){             int tmp = arr[b++];                 for(int i=++mid;i&gt;a;i--){                 arr[i]=arr[i-1];                 }             arr[a++]=tmp;                     }             else if (arr[b]&gt;arr[a]){             a++;             }             else{ //arr[b]=arr[a]                 if(a==mid &amp;&amp; b == end){                 break; //all between mid and end will be equal too                  }                 int tmp= arr[b++];                             a++;                 for (int i=++mid;i&gt;a;i--){                 arr[i]=arr[i-1];                 }                 arr[a++]=tmp;                 //a++;                 //b++;             }                     }             return arr;     }     }   modified my answer based on Manu's below. but it's still not working. Attaching code below:  public static void mergesort(int[] arr,int start,int end){         int mid = (end+start)/2;     if (end - start&lt;=0){         return;     }         else if (end-start&gt;=1){              mergesort(arr,start,mid);         mergesort(arr,mid+1,end);      }         merge(arr,start,end);         for (int i=0;i&lt;arr.length;i++){                System.out.print(arr[i]+ " ");         }         System.out.println();         return; }  public static void merge(int[] arr,int start,int end){         int mid= (start+end)/2;     if(start-end&lt;=0){         return;     }      int a= start; int b = mid+1;     while (a&lt;=mid &amp;&amp; b &lt;=end){         if (arr[b]&lt;arr[a]){         int tmp = arr[b++];             for(int i=++mid;i&gt;a;i--){             arr[i]=arr[i-1];             }         arr[a++]=tmp;                 }         else if (arr[b]&gt;arr[a]){         a++;         }         else{ //arr[b]=arr[a]             if(a==mid &amp;&amp; b == end){             break; //all between mid and end will be equal too (pearl)             }             int tmp= arr[b++];                         a++;             for (int i=++mid;i&gt;a;i--){             arr[i]=arr[i-1];             }             arr[a++]=tmp;             //a++;             //b++;         }                 }         return; } }
In Java, arrays don't override toString(), so if you try to print one directly, you get the className + '@' + the hex of the  of the array, as defined by Object.toString():  int[] intArray = new int[] {1, 2, 3, 4, 5}; System.out.println(intArray);     // prints something like '[I@3343c8b3'   But usually, we'd actually want something more like [1, 2, 3, 4, 5]. What's the simplest way of doing that? Here are some example inputs and outputs:  // Array of primitives: int[] intArray = new int[] {1, 2, 3, 4, 5}; //output: [1, 2, 3, 4, 5]  // Array of object references: String[] strArray = new String[] {"John", "Mary", "Bob"}; //output: [John, Mary, Bob]
Why does the Sun's (or other stars') nuclear reaction not use up all its "fuel" immediately? The temperature and pressure everywhere inside the Sun reach the critical point to start nuclear reactions - there is no reason for it to take such a long time to complete the reaction process.  Just like a nuclear bomb will complete all the reaction within $10^{-6}$seconds.  Why does most of the hydrogen of the Sun still not react even though it reaches the critical point, and why take stars billions of years to run out of fuel? How to get the Duke O' Death? I was watching some videos on YouTube showing how to get the Duke O' Death in GTA 5, however what I have seen is sort of unclear.  Some people say you must be a returning player on GTA 5 to get it (what does this mean too BTW?), some people don't say that. Some people say you have to be Trevor, some people don't. Some say the time of day matters, some don't. And apparently you can buy it from Warstock website (I can't).   Can someone please tell me how to get it?! GTA 5 came with my PS4 (I didn't play it on PS3) if that helps. How can I get a complete list of fields for a standard object? I am new to Apex, but it is apparent to me that most (if not all) standard objects probably have an ID field. However, this field does not appear in the reference for the standard objects in the Soap API Developer's Guide. Instead, it reads:     To verify the complete list of fields for an object, you can use a   describe call from the API, or inspect with an appropriate tool, for   example, inspecting the WSDL or using a schema viewer.   If I want to find out for sure whether an object has an ID field, or what the field is named (is it ID, Identifier, id, etc), it sounds like I need to use a "describe call" or "an appropriate tool" or inspect the "WSDL" using a "schema viewer".  Now, I am an experienced software developer, but those solutions are so ambiguous I have no idea where to look next to figure out how to get an object's ID. Can anybody either refer me to more specific documentation, or explain how to find the complete field documentation via a "describe call", "appropriate tool", or "schema viewer"? Finding $\frac{3}{1!+2!+3!}+\frac{4}{2!+3!+4!} +\frac{5}{3!+4!+5!}+\cdots+\frac{2008}{2006!+2007!+2008!}$ How to find :  $$\frac{3}{1!+2!+3!}+\frac{4}{2!+3!+4!} +\frac{5}{3!+4!+5!}+\cdots+\frac{2008}{2006!+2007!+2008!}$$ Convert NTFS to FAT32 without losing data I understand that you can  without formatting or backing up the data and later restoring - is the same thing possible in the other direction?  I want to convert my NTFS portable hard drive to FAT32 so that my PS3 will recognise it.  If it's not possible from within Windows, are there any free programs which will allow me to do it? How to download all files from Ubuntu One? Why does time change in Ubuntu after installing Windows Today I was installing Windows 7 on the same computer I have Ubuntu. For some reason, after installing Windows 7 and going back to Ubuntu the time went from the correct hour at that moment, 12:30PM to 7:30AM. This happened after installing Windows 7. For what I understand the BIOS has a time set, Ubuntu has the same time that is shown in the BIOS when installing it. At least up to this point is what I have seen. Now after installing Windows 7 (And believe me this is only for testing the performance of Windows 7 against Ubuntu in which case Windows 7 is falling behind a lot on the same hardware) the time changes in Ubuntu to the wrong one that is set in Windows 7.  I actually do not change the time in Windows 7 since this is one of the checks I am doing to see if the operating system can correctly grab the time. Windows 7 fails. Ubuntu does not BUT Windows 7 actually changes the time for Ubuntu if I boot with it afterwards.  So my question is, why/how does time change in Ubuntu after installing Windows.  NOTE - I have set Ubuntu time to "manual" instead of grabbing it from the Internet just to test out this. "Back" and "Install Now" buttons grayed out in 14.04 installer The "Back" and "Install Now" buttons are grayed out in the 14.04 installer. How do I restore them? How to remove the handles from this faucet My bathroom faucet is leaking around the base of my right handle.  With previous faucets I've been able to use a set screw to loosen the handle and replace the washer.  With these, though, I can't seem to pop off the faucet handle.  Does anyone know how to remove this handle?  Does anyone know the brand of this faucet?  Update -- Nov 29th  I've already tried to get those cap ends off.  I tried to use some pliers and unscrew them, but couldn't remove it.  I tried taking a small flat head and popping off the ends.  Still nothing.  It doesn't seem like the come off.  I also tried unscrewing the handles, but they just don't see to turn for me.  Also there is definitely no set screw on the handles.  I've searched all around the faucet and found nothing indicating a set screw. We now that Fermat's last theorem is true so there are not positive integer solutions to $$x^n+y^n=z^n$$ for $n\in\mathbb{N}$ and $n&gt;2$.  But what about if $n\in\mathbb{R}$ or $n\in\mathbb{R}^+$? Cannot remove any bluetooth device My phone was just stolen an hour or so ago. Are there any options for tracking? I realize this is a long shot, but my phone was lost or stolen a few hours ago.  At the time it was stolen, I didn't have any specific applications installed to track it or wipe the data. So... my bad. I'm hoping the fact that I have a pattern lock will at least prevent anyone from accessing my data.  My question is, do I have any options for tracking or data wipe after the fact? (I'm more interested in tracking.)  Note: I have read similar questions, but unless I'm mistaken, they all address the question in terms of preparation before losing the phone. I'm asking about fallback options after losing the phone. How to remove "onclick" with JQuery? Unfortunately, despite having tried to learn regex at least one time a year for as many years as I can remember, I always forget as I use them so infrequently. This year my new year's resolution is to not try and learn regex again - So this year to save me from tears I'll give it to Stack Overflow. (Last Christmas remix).  I want to pass in a string in this format {getThis}, and be returned the string getThis. Could anyone be of assistance in helping to stick to my new year's resolution?    Related questions on Stack Overflow: Prove that $371\cdots 1$ is not prime Prove that $371\cdots 1$ is not prime.   I tried mathematical induction in order to prove this, but I am stuck.  My partial answer:  To be proved is that $37\underbrace{111\cdots 1}_{n\text{ ones}}$ is never prime for $n\geq 1$. Let $P(n)$ be the statement that $37\underbrace{111\cdots 1}_{n\text{ enen}}$ is not prime.  For $n=1$, we can write $371=7\cdot 53$, and therefore $P(1)$ is true. Let $P(k)$ be true for $k&gt;1$. Then we now have to prove that $P(k+1)$ is true.  I found that $37\underbrace{111\cdots 1}_{k\text{ ones}}$ can be written as $37\cdot 10^k+10^{k-1}+10^{k-2}+\cdots +10^0$ and that $37\underbrace{1111\cdots 1}_{k+1\text{ ones}}$ can be written as $37\cdot 10^{k+1}+10^{k}+10^{k-1}+\cdots+10^0$.  I think I'm pretty close to the answer know, but I don't know how to proceed. How to backup 20+TB of data? We have a NAS server at the company I work for that is being used for storing photography sessions. Each session is approximately 100gb. Over the last couple of years this server has accumulated 10+ TB of data, and we are increasing the amount of photoshoots exponentially. I estimate that by the end of next year we will have 20+ TB stored on this NAS. We are currently backing this server up to tape using LTO-5 tapes with Symantec BackupExec. Since the size of this server has grown, full backups of this server are not completing overnight. Does anyone have any suggestion on how to backup this amount of data? Should we be backing it up to tape? Are there any other options which may be better? I'm unable to upgrade Xcode 11GM to 11.1 for some time on my Mid 2014 MacBook Pro running macOS Catalina. I've installed Xcode from Mac AppStore ages ago (IIRC circa 2014), and upgraded step by step since then. Currently, I'm experiencing the following loop:   AppStore reports that I have an update. I open AppStore, open updates, click "Update" on Xcode. Mac Downloads ~2.5GB first. Installs that patch. Continues to get the full package (~7.6GB). It starts to install. After some churning and install, it reports "Cannot download Xcode now, please try again later."   I have more than enough space on the disk, and nothing is modified in Xcode or in the OS (no homebrew or something similar).  Did anyone experience something similar? Are there solutions to this? My intent is to show that a composition of bijections is also a bijection by showing the existence of an inverse.  But my approach requires the associativity of function composition.  Let $f:  X \rightarrow Y, g:  Y \rightarrow Z, h:  Z \rightarrow W$ be functions.  $((f \circ g) \circ h)(x) = h((f \circ g)(x)) = h(g(f(x)))$, and $(f \circ (g \circ h))(x) = (g \circ h)(f(x)) = h(g(f(x)))$.  However, I am having problems in justifying that the two compositions, $(f \circ g) \circ h$ and $f \circ (g \circ h)$, have the same domain and range.  When I consulted ProofWiki, whose link is at the bottom, I got even more confused.  Specifically, for $(f \circ g) \circ h = f \circ (g \circ h)$ to be defined, ProofWiki requires that dom$g =$ codom$f$ and dom$h =$ codom$g$.  First of all, I think that it should be dom$g =$ range$f$ ....  Moreover, as you can see in the example below, you actually have to adjust domains and ranges of $f, g, h$ for the requirement to hold true.  Let $f: \mathbb R \rightarrow \mathbb R$ be $f(x) = 2x$, $g: \mathbb R^+ \rightarrow \mathbb R$ be $g(y) = ln(y)$, $h: \mathbb R \rightarrow \mathbb R$ be $h(z) = z - 10$.   Then $((f \circ g) \circ h)(x) = ln(2x) - 10 = (f \circ (g \circ h))(x)$, with dom$((f \circ g) \circ h) = \mathbb R^+$ = dom$(f \circ (g \circ h))$.  As a result, we need to set dom$f = \mathbb R^+$, range$f = \mathbb R^+$; dom$g$, range$g$, dom$h$, and range$h$ remain the same.  Am I allowed to do that?  This adjustment implies that when we say dom$f = X$, $f$ must be defined for all elements in $X$, but $X$ may not be the entire set of elements for which $f$ is defined. How can I use an array modifier to create individually manipulatable objects? DSolve gets stuck on system of differential equations with unassigned variable