In Java, object reference is used for call by reference and variables are used for call by value.  Here’s an example:  class Foo{     int x;     int y; }     public class CallByRef {     public static void main(String[] args) {                     Foo foo = new Foo();         foo.x=5;         foo.y=10;         System.out.println(foo.x+", "+foo.y);         getFoo(foo);         System.out.println(foo.x+", "+foo.y);     }         static void getFoo(Foo f){         f.x=2;         f=new Foo();         f.x=10;     } }   Output:      5, 10     2, 10   Why this is happend?  x should be 10 as I modified its value with f.x=10  Is it correct that f=new Foo() will create new object in heap and not point to prevoise reference?
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?
Why does "under the sea" mean "in the sea"? Reputation in summary tab shows as blank instead of 0, if net result is zero Are there any organised resources available from where I can begin my quantum computing studies? I am a computer science student and am currently searching for resources from where I can learn about quantum computers, quantum computing models, their working principles, their gates and some simple quantum algorithms. I am running linear regression models and wondering what the conditions are for removing the intercept term.   In comparing results from two different regressions where one has the intercept and the other does not, I notice that the $R^2$ of the function without the intercept is much higher. Are there certain conditions or assumptions I should be following to make sure the removal of the intercept term is valid? Prime ideal and nilpotent elements When should I use the subjunctive mood? In which cases should I use the subjunctive mood?     I suggest that every applicant fill out the form carefully.        If she were rich, she would live on Long Island. Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit? I am being considered for a very nice industry scientist position but this involves many interviews and assessments and can take some time.  However I have also accepted an invitation to the US (I'm in Australia) to give a presentation in relation to high likelihood of employment as a postdoc in a research institute.  The postdoc supervisor has arranged for sightseeing and lab visits and hotels. I feel bad if somehow I wish to pursue the industry position.  Has anyone had a similar experience and have you turned down something like that before? Conditional expection of gamma distribution on sum I have a process which consists of a number of events and what is known is the timings between the events. What I'm trying to determine is a distribution that allows me to determine a likelyhood that a new sample fits the distibution.  The issue is mainly that if you have lots of samples you can approximate the result using a standard gaussian and use the mean and standard deviation. But if you only have a handful of samples, the gaussian does not accurately represent the situation.  From what I've read it is common to model waiting times using the gamma distribution. Looking at how the process evolves it looks like it matches well. The unknown is the scale parameter, since the shape parameter I think should be the number of samples. What I've worked out so far is that given the timings $X_1 ... X_N$ you can say:  $$ \sum_{n=1}^N X_n \sim \Gamma(N,\theta) $$  ($N$ is known and fixed)  However, $\theta$ is unknown, but the maximum likelihood parameter is the average of the $X_i$ (according to wikipedia anyway).   My question is, can I use this to estimate a distribution for $X_i$, that is, since the $X_i$ are independent:  $$ N X_i | \sum_n X_n \sim \Gamma(N, \tfrac{1}{N}\sum_n X_n) $$  Something else I've wondered about. Suppose I do have information about $\theta$, say a distribution. How can I incorporate this into the model?  Edit: Clarified that N is fixed. How can I remap a keyboard key? What is the Python equivalent of Perl's chomp function, which removes the last character of a string if it is a newline? Is there a proof from the first principle that the Lagrangian L = T - V? Is there a proof from the first principle that for the Lagrangian $L$,    $$L = T\text{(kinetic energy)} - V\text{(potential energy)}$$  in classical mechanics? Assume that Cartesian coordinates are used. Among the combinations, $L = T - nV$, only $n=1$ works. Is there a fundamental reason for it?  On the other hand, the variational principle used in deriving the equations of motion, Euler-Lagrange equation, is general enough (can be used to to find the optimum of any parametrized integral) and does not specify the form of Lagrangian. I appreciate for anyone who gives the  answer, and if possible, the primary source (who published the answer first in the literature).      Notes added on Sept 22: - Both answers are correct as far as I can find. Both answerers were not sure about what I meant by the term I used: 'first principle'. I like to elaborate what I was thinking, not meant to be condescending or anything near to that. Please have a little understanding if the words I use are not well-thought of. - We do science by collecting facts, forming empirical laws, building a theory which generalizes the laws, then we go back to the lab and find if the generalization part can stand up to the verification. Newton's laws are close to the end of empirical laws, meaning that they are easily verified in the lab. These laws are not limited to gravity, but are used mostly under the condition of gravity. When we generalize and express them in Lagrangian or Hamiltonian, they can be used where Newton's laws cannot, for example, on electromagnetism, or any other forces unknown to us. Lagrangian or Hamiltonian and the derived equations of motion are generalizations and more on the theory side, relatively speaking; at least those are a little more theoretical than Newton's laws. We still go to lab to verify these generalizations, but it's somewhat harder to do so, like we have to use Large Hadron Collider. - But here is a new problem, as @Jerry Schirmer pointed out in his comment and I agreed. Lagrangian is great tool if we know its expression. If we don't, then we are at lost. Lagrangian is almost as useless as Newton's laws for a new mysterious force. It's almost as useless but not quite, because we can try and error. We have much better luck to try and error on Lagrangian than on equations of motion. - Oh, variational principle is a 'first principle' in my mind and is used to derive Euler-Lagrange equation. But variational principle does not give a clue about the explicit expression of Lagrangian. This is the point I'm driving at. This is why I'm looking for help, say, in Physics SE. If someone knew the reason why n=1 in L=T-nV, then we could use this reasoning to find out about a mysterious force. It looks like that someone is in the future. Prove that if $f$ is a real continuous function such that $|f|\le 1$ then $|\int_{|z|=1} f(z)dz| \le 4$ I've encountered the following problem in complex analysis:  Prove that if $f$ is a real continuous function such that $|f|\le 1$ then $|\int_{|z|=1} f(z)dz| \le 4$.  I've decomposed $f$ to it's real and imaginary parts and got that it's enough to prove that:  $(\int_0^{2\pi}cos(\theta)g(\theta)d\theta)^2 +(\int_0^{2\pi}sin(\theta)g(\theta)d\theta)^2 \le 16$   Where $g(\theta)=f(e^{i\theta})$.   But now I'm stuck. Any ideas?  Thanks Here is a quesion that has been bugging me. You know how you can set up a program to run on start up right?  Well, how can i tell it to start minimized, like you would do in windows?   TeamViewer starts open, but I need it minimized, and Tray-it just doesn't seem as elegant of a way to do it. How do you get your Google+ profile displayed in the right hand sidebar of the Google search results page? So when we view reputation, there is graph view. However, it seems to be off by a day. Here's what I mean:   I'm sure 70 + 20 + 15 is not 15. Its 105, which is what we see below:   And 40 + 10 is NOT 105, unless you did  :)     Anyways 40 + 10 is 50:   So yeah. Did you do what that post on codegolf says? Devs better fix that :) Calculating $\lim_{x\to+\infty}(\sqrt{x^2-3x}-x)$ Let $f(x) = \sqrt{x^2-3x}$ and $g(x) = x$. Calculate the following limits, showing all working.  I've done the first two -   $$\lim_{x\to0}f(x)\\ =\lim_{x\to0}\sqrt{x^2-3x}=0$$  $$\lim_{x\to-\infty}\frac{f(x)}{g(x)}\\ =\lim_{x\to-\infty}\frac{\sqrt{x^2-3x}}{x}=\sqrt{1-\frac{3}{x}}=1$$  How do I calculate this one?  $$\lim_{x\to+\infty}(f(x)-g(x))$$ Filling triangle doesn't seem to work with PGF/TikZ I was wondering if anyone had any clue on why my triangles are not filled in red within the following piece of code:  \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc,3d}  \usepackage[active, pdftex, tightpage]{preview} \PreviewEnvironment[{[]}]{tikzpicture} \newcounter{number}  \begin{document} \begin{tikzpicture}[x  = {(-0.5cm,-0.5cm)},                     y  = {(0.9659cm,-0.25882cm)},                     z  = {(0cm,1cm)}] \begin{scope}[canvas is yx plane at z=0] \foreach \x / \y / \label in {1 / 0.4 / 1, 0.9 / 0.4 / 0, 1 / 0.5 / 1, 0.7 / 0.3 / 0, 0.8 / 0.4 / 0, 0.9 / 0.5 / 0, 1 / 0.6 / 1, 0.7 / 0.4 / 0, 0.4 / 0.4 / 0, 0.6 / 0.4 / 0, 0.5 / 0.4 / 0, 0.8 / 0.5 / 0, 0.9 / 0.6 / 0, 1 / 0.7 / 1, 0.7 / 0.5 / 0, 0.5 / 0.5 / 0, 0.4 / 0.5 / 0, 0.6 / 0.5 / 0, 0.8 / 0.6 / 0, 0.9 / 0.7 / 0, 1 / 0.8 / 1, 0.7 / 0.6 / 0, 0.6 / 0.6 / 0, 0.5 / 0.6 / 0} { \addtocounter{number}{1} \pgfmathparse{\value{number}}\let\k\pgfmathresult \draw (8 * \x, 8 * \y) node[inner sep=0, outer sep = -0.1pt,color=black,fill,circle] (node-\k) {}; };  \foreach \x / \y / \z / \trash in { 4/5/8/0, 9/11/16/0, 9/16/17/0, 11/10/18/0, 11/18/16/0, 10/8/15/0, 10/15/18/0, 8/5/12/0, 8/12/15/0, 5/2/6/0, 5/6/12/0, 2/1/3/0, 2/3/6/0, 17/16/24/0, 16/18/23/0, 16/23/24/0, 18/15/22/0, 18/22/23/0, 15/12/19/0, 15/19/22/0, 12/6/13/0, 12/13/19/0, 6/3/7/0} { \draw[fill=red]  (node-\x) --  (node-\y) --  (node-\z) -- cycle; } \end{scope} \end{tikzpicture} \end{document}) Log of products to sum of logs Do we have $\lim_{h\to 0^+}\int_0^\infty|f(t+h)-f(t)|dt=0$? Let $f:\mathbb{R^+}\to\mathbb{R}$ be an integrable function ($f\in L^1(\mathbb{R}^+,\mathbb{R})$). Do we have $$\lim_{h\to 0^+}\int_0^\infty|f(t+h)-f(t)|dt=0$$ ? How can we prove it ? Proving a three variables inequality