I just got back my Java test paper and there is one question that has been bugging me.  There was a question:  What is the output of the following program?  public class Swap {     public static void swap(int[] a){         int temp = a[1];         a[1] = a[0];         a[0] = temp;     }      public static void main(String[] args){         int[] x = {5,3};         swap(x);         System.out.println("x[0]:" + x[0] + " x[1]:" + x[1]);     } }   The thought that first came to my mind was that this was a trick question. Since the swap method return type was void, I thought that it had no effect on the int[] x array. My answer was x[0]:5 x[1]:3. I was almost certain that I got the correct answer and when I saw that I had been marked wrong, I got confused. I went to try out the actual code on NetBeans and realized that the values in the array actually got swapped! I then went on to test if this was the case for String. I typed in a similar but different code:  public class Switch {     public static void switch(String s){         s = "GOODBYE";     }      public static void main(String[] args){         String x = "HELLO";         switch(x);         System.out.println(x);     } }   The output still printed HELLO instead of GOODBYE. Now my question is why does the method not change the String but it changes the values inside an array?
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?
I have an internet connection that I'd like to be enabled only during the day. With multiple household internet devices, this would need to be something disabled at the level of the router.  I don't believe the router offers this sort of functionality, but I'm reasonably familiar with setting up web servers and the like, and I'm wondering if I can set up some sort of proxy server on the internet that the router must go through and have that proxy only active at certain times of day.  It's a bit vague I know, but is something like this even possible?  If not, are there other solutions to the problem? Is there a word for saying "um" or "uh", etc, during speaking?  Or a word for "um" and "uh", etc? I did apt-get upgrade it never finishes at this point:  Searching for GRUB installation directory ... found: /boot/grub Searching for default file ... found: /boot/grub/default Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst Searching for splash image ... none found, skipping ... Found kernel: /boot/vmlinuz-3.2.0-24-virtual Updating /boot/grub/menu.lst ... done  You already have a NoLOADER configuration in /etc/grub.conf Running boot loader as requested Running /usr/sbin/grub  ...    The system does not freeze (Ctrl-Z works, I get my console back) just that that /usr/sbin/grub seems to never complete.  What should I do? This lock notice about collaborative effort is partly misleading is locked  with the following notice:     This question and answer are a collaborative effort: if you see something that can be improved, edit it!    Except that while the answer can be edited because it's a Community Wiki question, the question itself  can't be, because it's locked. I don't know the reason why it was locked, but maybe the notice's text should be changed or omitted? (I have no opinion on whether the question should stay locked or not.) Here's what I remember about it:   The protagonist is sent a relatively short distance into the future (maybe a year? I've forgotten). When he arrives in this "future" he finds himself in a completely different world, with non-human inhabitants. The inhabitants use a machine to teach him their torturous language. He tries to return home, and (eventually) finds himself in a realm of chaos/nothingness. He laboriously reconstructs in his mind everything he can remember about his home and finds himself back there somehow. The twist is      that in his "home" reality everyone speaks the language he was taught by the non-human inhabitants at his first stop. Prove $ \sin x + \frac{ \sin3x }{3} + ... + \frac{ \sin((2n-1)x) }{2n-1} >0 $ Prove that for $ 0&lt;x&lt; \pi $, $$ \quad S_n(x) = \sin x + \frac{ \sin3x }{3} + ... + \frac{ \sin((2n-1)x) }{2n-1} &gt;0 \quad \forall n = 1,2,... $$  Having trouble with this problem. This is an olympiad-style question, so an answer that doesn't use calculus or analysis would be preferred. A possible approach is induction, but for this we need to find a function in terms of $n$ and $x$ so that we can actually use the inductive step. If anyone has any ideas they would be appreciated.  If you really want to go down the calculus route (at this point I don't mind), then $ S_n' (x) = \cos x + \cos 3x + ... +\cos((2n-1)x) $ , which you can find a closed form for, but I don't know how useful that is. How can I explain to people that the phrase “off of ” is grammatically incorrect? I need to rename a bunch of files in order to fix their sort order, therefore I need to be able to do a sort of "find and replace" so I can replace chunks of the filenames at a time.  What tools should I use? I prefer GUI but a command line tool recommendation would also be fine. I have an Samsung Galaxy S3 Neo.  Bus 002 Device 042: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-I9300 Phone [Galaxy S III], GT-P7500 [Galaxy Tab 10.1]   The keyboard &amp; language setting is português.  I today installed Android Device Manager and to test it's functionality I locked the phone with the password: "abcd" (4 letters were required).  After entering the password and confirming with the "OK" button of my keyboard, the phone showed me that the password is wrong. "Senha incorreta".  I reset the password after some tries to "123456" and the phone reloaded the lock screen. Again the password showed up to be wrong. I also tried the alphabetic password: "abcdefg" - same error.  I changed the language of my Google account from German to Portuguese and reset the password to "123456" again and I tried to really reboot my phone and unlock the SIM card again. But anyways I can not get through my lock of the Android Device Manager.  I tried to enter the password 35 times wrong with hope to get a chance to authenticate with my Google Account login.  I also tried to connect the phone with adb but it does not show up in this state with:  adb devices   So what can I do to get access to my phone again? Big-O Notation Proof Given the definition of Big-O, prove that $f(n) = n^2 - n$ is $O(n^2)$.  When I use the given definition, I get $n^2 - n \leq n^2 - n^2$ which means that $n^2 -n \leq 0$, which is not true. Is there some step I'm missing? Transit Visa for Thailand Im an Indian citizen. Do I need a transit visa in Thailand while going to Angkor Wat from Kolkata (India), and can I stay in Thailand for two days on this transit visa? Correcting for multiple kruskal wallis tests Origin/reason for the expression "on the bus" instead of "in the bus" This is sort of a follow up to my question .  I was told a while ago that the reason why we use "on the bus" instead of "in the bus" is because back in the day buses were open, that is, they didn't have a roof.   Is this story correct or is there another reason why the correct expression is "on the bus", in spite of the fact that when one gets on the bus, he is actually inside the bus? Leg bisectors in a trapezoid and angle equality Let $PQRS$ be a trapezoid. The bisectors of legs $PS$ and $QR$ intersect the opposite legs at $M$ and $N$ so that triangles $PMS$ and $QNR$ are formed.  Prove that $\measuredangle PMS= \measuredangle QNR$.  The question may seem easy but I fail to move on, playing with angles didn't help. I'd appreciate some hint from somebody with an eye for geometry and triangles. As you can see, the off-topic page isn&#39;t quite right...    Could this (minor) issue be fixed? How can I modify title page so that it looks like it is in  video. Please seek to 16 seconds and watch title page. I do not have permission to post images. I liked this theme and I want to make a beamer theme that looks similar. I tried with beamercolorbox but I failed to position the box to the bottom.      Edit: Here is my minimum working example  \documentclass[xcolor=dvipsnames]{beamer} \defbeamertemplate*{title page}{customized}[1][] { \usebeamerfont{subtitle} \usebeamercolor[fg]{subtitle}  {\flushright \setbeamercolor{author}{bg=white,fg=Red} \usebeamerfont{author} \insertauthor\par \usebeamerfont{institute}\insertinstitute\par }  \vspace{0.2in}  \setbeamercolor{postit}{fg=white,bg=YellowOrange}  \begin{beamercolorbox}[sep=1em,wd=1.062\textwidth,ht=3cm,dp=3cm,right]{postit} \usebeamerfont{title} {\huge \inserttitle}\par \usebeamerfont{subtitle} {\insertsubtitle} \end{beamercolorbox} } \usecolortheme[named=YellowOrange]{structure} \useoutertheme{infolines} \setbeamertemplate{navigation symbols}{}  \institute{Harvard College Professor and\\ Johnstone Family Professor in Psychology, Harvard University}  \title{SAY WHAT?} \subtitle{Linguistics as a Window to\\ Understanding the Brain} \author{Steven Pinker}  \begin{document} { \setbeamertemplate{footline}{} \begin{frame} \titlepage \end{frame} } \end{document} Introduction to Statistical Learning defines the F-statistic as follows: $$\frac{(TSS - RSS) / p}{RSS / (n - p - 1)}$$ I am trying to interpret this formula intuitively - the numerator looks like the $ESS$ per regressor, and the denominator looks like the $RSS$ per observation. This does not seem like an apples to apples comparison; can anyone explain why it makes sense?  They also say that the expectation of the denominator is equal to the variance of the irreducible error if the linear model assumptions hold (I get this, as the denominator is really the Residual Standard Error, which is an unbiased estimator). They also say the numerator is equal to the variance of the irreducible error if the null hypothesis is true. Therefore the F-statistic will be close to 1 if the null hypothesis is true.  But if you let p = 1, that is, apply the F-statistic to single linear regression, it becomes:  $$\frac{TSS - RSS}{RSS / (n-2)}$$  According to the book, if the regressor has no explanatory power, the F-statistic should be close to 1. But if you imagine a data set where the coefficient on X is 0 (i.e. no explanatory power), $TSS$ will be equal to $RSS$, so the numerator and hence the F-statistic should be 0, not 1 as they claim. What is going on?  Furthermore, if you accept that the F-statistic is 1, as they claim, then $(TSS - RSS) = RSS / (n-2)$, which means $ESS = RSS / (n-2)$. If you think of the F-statistics as comparing explained vs. unexplained variation, this does not seem like a fair comparison since this decomposition makes it the ratio of TOTAL explained variation summed across ALL observations vs. the unexplained variation PER observation. Again, what am I missing?  I am just trying to make sense of it in a layman way, apologies if I am missing something obvious. How to redirect stderr and stdout to different files and also display in terminal? I want to see the output of a command in the terminal as if there was no redirection.  Also, stderr needs to be redirected to err.log and stdout needs to be redirected to stdout.log.  It would be nice to also have the exact copy of what is shown in terminal, i.e. errors printed as and when it occurs, in a separate file: stdouterr.log. In 2018, Kyle Reese (a normal civilian who wasn't part of Resistance) was on the top in the hit list of Skynet. It means that Skynet of that time had information from future about Kyle Reese being father of future leader of human resistance. Right?  Why didn't Skynet kill Kyle Reese instantly after his detection kicking John Connor out of existence? Troubleshooting "Windows cannot be installed to this disk. The selected disk has an MBR partition table" I recently bought a desktop computer with Windows 7 Home Premium x64 preloaded (OEM). I tried to install Windows 7 Ultimate x64 on this computer but I was presented with the following error message:     Windows cannot be installed to this disk. The selected disk has an MBR   partition table. On EFI systems, Windows can only be installed to GPT   disks.   The 1TB HDD on this computer has three partitions:   SYSTEM 100 NTFS - Healthy (System, Active Primary Partition)  OS (C:) 9148.04 GB NTFS - Healthy (Boot, Page File, Crash Dump, Primary Partition)  HP_RECOVERY (D:) 13.37 GB NTFS - Healthy (PrimarynPartition)   I'm trying to install a clean copy of Windows.