Why does my Java(Android) method modify parameters that get passed in I've got a Java method that takes a Calendar as a parameter, calculates some date before the provided date, and returns this new Calendar. Now, if I log the values of the first Calendar, initialize a new Calendar as the value of the returned Calendar, then log them both, they're shown to be the same date. Why does the method return the value of start and also change the value of startDate in the main method? Section of code that passes a Calendar to the method Dating.getStartDate(); Calendar endDate = Calendar.getInstance();  Log.i(&quot;DATING&quot;, &quot;End Date = &quot; + endDate.getTime());          Calendar startDate= Dating.getStartDate(endDate);          Log.i(&quot;DATING&quot;, &quot;Start Date = &quot; + startDate.getTime()); Log.i(&quot;DATING&quot;, &quot;End Date = &quot; + endDate.getTime());  The Method: public static Calendar getStartDate(Calendar end) {          Calendar start;      Log.i(&quot;DATING&quot;, &quot;Calculating 100 previous occurrences&quot;);     for (int count = 0; count &lt; 100; count++){         start = getPreviousOccurrence(end);      // Calculates some day before end         end = start;                             // sets end to new value of start     }     Log.i(&quot;DATING&quot;, &quot;getStartDate() returning start date of &quot; + start.getTime());     return start; }  And here is the log output: I/DATING: End Date = Sat Jan 09 23:13:04 EST 2021 I/DATING: Calculating 100 previous occurrences I/DATING: getStartDate() returning start date of Sat Jan 25 23:13:04 EST 2020 I/DATING: Start Date = Sat Jan 25 23:13:04 EST 2020 I/DATING: End Date = Sat Jan 25 23:13:04 EST 2020
Is Java "pass-by-reference" or "pass-by-value"? 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 know that IList is the interface and List is the concrete type but I still don't know when to use each one. What I'm doing now is if I don't need the Sort or FindAll methods I use the interface. Am I right? Is there a better way to decide when to use the interface or the concrete type? Some conditions require that a person lie in bed all the time until recovered. Is there a name for such conditions or people experiencing them at the moment?   For example,      I am currently &lt;bed sick&gt; and can't help you with your homework.   I tried looking for bed sick but hit a dead end. What tense should I use to describe something in the past but probably is still true? The title may be a bit confusing. See the below example:     The movie (was/is) so good.   The simplest guideline on deciding which tense to use, past tense or present tense, to describe an object comes down to whether the description was only true that that time or is true even to the present point of time.  But now we talking about literary work(movies,books,etc) of which quality tend to stay the same over time, which tense should we use? Find a recurrence relation for the number of ternary strings of length n that do not contain two consecutive 0s or two consecutive 1s. Note: Problem from "Kenneth Rosen's DM and it's applications" and solution from "Students solution guide for use with ... applications"  Let P(n) be the number of strings not containg two containing two consecutive zeros or two consecutive ones.  I got the answer  P(n)=P(n-1)+2P(n-2)+2P(n-3)+...+2P(0) +2  but then the book says the sequence also satisfies the recurrence relation  P(n)=2P(n-1)+P(n-2). I am not able to understand this part. Is there any substantial disadvantage to booking two one-way tickets, versus a round trip ticket?  Booking vacation travel with family of four for winter, from Northeast US to Mexico.  Round trip is pricy and no preferred travel times.  Two one ways is slightly cheaper with much preferred timing.      Different airlines there and back, both reputable national US carriers. What we've gelost — why doesn't English use the prefix "ge-"? The Germanic languages that I'm familiar with all use a prefix similar to ge- on past participles:  German: Ich habe mir den Fuß gebrochen. Dutch: Ik heb mijn voet gebroken.  But English doesn't do this at all:  English: I've broken my foot.  Where did this prefix come from? Did English ever have the ge- past participle prefix? If so, why was it lost? Find the Resistance between Two Terminals Let's say R = 49 ohms, and we want to find Req between a and d, how do we do that? Do we have to find Req for the whole circuit? How can i integrate one SFDC org to another SFDC using Rest Api I am trying to integrate one Salesforce org to other org by using Oauth setup, I wanted to use  use consumer key and consumer secret key in my REST class to connect with the org, after connection part completion, I want to access Get(), Put(), Post(), etc. Including the ability to set Oauth and Authorization headers needed for Salesforce Rest API calls.  Actually I'm new in REST implementation so can you please explain me by using code samples. Are functions of independent variables also independent? I'd like to do the equivalent of the following in LINQ, but I can't figure out how:  IEnumerable&lt;Item&gt; items = GetItems(); items.ForEach(i =&gt; i.DoStuff());   What is the real syntax? I have no root access on this machine.  I would like to know if there is a way I can download Ubuntu packages and install them as non-root?  Probably in my ~/bin or ~/usr/share or something like that? Would that work? I use LINQ to Objects instructions on an ordered array.  Which operations shouldn't I do to be sure the order of the array is not changed? Limits, find a limit that exist in absolute value but not outside the absolute value. Let I be an open interval that contains the point c and let f be a function that is defined on I except possibly at the point c. Suppose that lim |f(x)| as x->c exists. Give an example to show that lim f(x) as x->c may not exist.   Not really sure of an example for this? I am trying to solve the following question which is Ex3 from Arthur Engel, Problem Solving strategies. Here is the question: $\sum_{k=1}^n k^3 {n \choose k}$ and asks to find the sum. I am sincerely having a hard time trying to figure out how to solve it and get $n^2 (n+3)(2)^{n-3}$. I would really appreciate if someone could show the step-by-step process. Thank you! Set a global policy for floats positioning I have a document with many floats (figures, specifically).  I want to be able to change the global floats positioning policy from htbp to just h (or even H with the floats package).  For my-own reasons, I don't want to do this by appending the [h] argument to each float env.  One option that I can think of is using a macro:  \newcommand{\mypos}{h} % or htbp \begin{figure}[\mypos]...   I also prefer not to do that - It is cumbersome.  Is there a way to set the global float positioning argument globally? Schengen visa in US without H1B stamp Can I make `find` return non-0 when no matching files are found? Seems that I just proved $2=4$. I was reading through some of the questions and answers here on the Rings of Power and I just wondered why the ring effects, affected different races in a slightly different way.  I know other questions ask and answer some of these things, but I just wondered why the Rings of Power caused greed in Dwarves for ever more amounts of treasure.  It's true that Dwarves loved mining and loved wealth and were built of sturdier stuff than men, but why did the Rings of Power not control Dwarves in the way the other Rings of Power controlled men and why did it produce greed and not invisibility? Can we search posts by number of comments?