WeakHashMap is an implementation of Map interface where the memory of the value object can be reclaimed by Grabage Collector  if the corresponding key is no longer referred by any section of program. So if key is no longer used in program. its Entry object will be garbage collected irrespective of its usage. Its clear till here  This is different from HashMap where the value object remain in HashMap even if key is no longer referred. We need to explicitly call  remove() method on HashMap object to remove the value. calling remove will just remove the entry from map. Its readyness for GC will  depend whether  it is still used somewhere in program or not.    Usage of WeakHashMap over HashMap as per mine understanding  My understanding is we should go for WeakHashMap only when we want to ensure that value object is reclaimed by Grabage Collector when   key is no longer referred by any section of program. This makes program memory efficient Is my understanding correct here?  Usage of WeakHashMap as per  , i could spot this statement     This class is intended primarily for use with key objects whose equals   methods test for object identity using the == operator.   I did not get what above statement meant and how it contrast with mine understanding of WeakHashMap usage. Actually i did not get how this statement is related to usage of WeakHashMap?  UPDATE:-  on further carefully reading below statement the javadocs     An entry in a WeakHashMap will automatically be removed when its key   is no longer in ordinary use. More precisely, the presence of a   mapping for a given key will not prevent the key from being discarded   by the garbage collector, that is, made finalizable, finalized, and   then reclaimed. When a key has been discarded its entry is effectively   removed from the map, so this class behaves somewhat differently from   other Map implementations.   i am revising my understanding for the benefit of me and others  Usage of WeakHashMap over HashMap as per mine revised understanding  We should go for WeakHashMap only when we want to ensure that key-value pair is removed from map on GC run  when key is no longer in ordinary use other than map itself.  Examples are :-      WeakHashMap&lt;Integer, String&gt; numbers = new WeakHashMap&lt;Integer, String&gt;();     numbers.put(new Integer(1), "one");// key only used within map not anywhere else     numbers.put(new Integer(2), "two");     System.out.println(numbers.get(new Integer(1))); // prints "one"     System.gc();     // let's say a garbage collection happens here     System.out.println(numbers.get(new Integer(1))); // prints "null"     System.out.println(numbers.get(new Integer(2))); // prints "null"       Object key = new Object();     m1.put(key, c1);     System.out.println(m1.size());     key = null or new Object() ; // privious key only used within map not anywhere else     System.gc();     Thread.sleep(100);     System.out.println(m1.size());
The use of weak references is something that I've never seen an implementation of so I'm trying to figure out what the use case for them is and how the implementation would work. When have you needed to use a WeakHashMap or WeakReference and how was it used?
As I understand, correct plural versions of passerby and attorney general become passersby and attorneys general.  But why?  With passerby, the the preposition "by" has been combined with the noun "passer" to become a one word noun "passerby".  So why shouldn't this be passerbys?  If I am an attorney general, and you are an attorney general, why are we not attorney generals?  As an American I have always heard it as attorneys general, however  suggests British English does use "attorney-generals" (as well as an interesting 2nd paragraph that further probes my question).  Are there hard rules to this topic?  Or merely generally accepted practices based on locale? Matrix algebra: If $A^2=0$, Proof rank(A) $\le \frac{n}{2}$ What is the speed of sound in space? Given that space is not a perfect vacuum, what is the speed of sound therein? Google was not very helpful in this regard, as the only answer I found was $300\,{\rm km}\,{\rm s}^{-1}$, from , which is not a source I'd be willing to cite. Let $f$ and $g$ be entire functions such that $f^n+g^n=1$, where $n\geq 3$ is an integer. Prove that $f$ and $g$ are constant.  I suppose I should somehow prove that either $f$ or $g$ is bounded so that I can apply Liouville's Theorem, but I don't see how. I tried setting the derivative of the left hand side equal to zero and work with that but that did not seem to work. Installing to SDCard by default What can I do about uncounterable spells? I cast , sacrificing my only creature to kill my opponent.  My opponent responds with , which will win the game the other way.  Last Word says "This spell can't be countered."  What else can I do about it besides countering it to prevent my plans from being foiled?  (I'd really like to have the last word here.)    Historic Note: before of the April 2018 rules change, uncounterable spells with targets used to actually have different wording (still visible on the printed cards) implying that they still could be countered.  For example, Last Word said:     Last Word can't be countered by spells or abilities.   Meanwhile Akroma, Angel of Fury said:     Akroma, Angel of Fury can't be countered. Finding $\tan t$ if $t=\sum\tan^{-1}(1/2t^2)$ I am solving this problem. If $$\sum\limits_{i=1}^{\infty} \tan^{-1}\biggl(\frac{1}{2i^{2}}\biggr)= t$$ then find the value of $\tan{t}$.   My solution is like the following: I can rewrite: \begin{align*} \tan^{-1}\biggl(\frac{1}{2i^{2}}\biggr) &amp; = \tan^{-1}\biggl[\frac{(2i+1) - (2i-1)}{1+(2i+1)\cdot (2i-1)}\biggr] \\\ &amp;= \tan^{-1}(2i+1) - \tan^{-1}(2i-1) \end{align*}  and when I take the summation the only term which remains is $-\tan^{-1}(1)$, from which I get the value of $\tan{t}$ as $-1$. But the answer appears to be $1$. Can anyone help me on this. How to parse a string to an int in C++? What's the C++ way of parsing a string (given as char *) into an int? Robust and clear error handling is a plus (instead of ). Suppose $\displaystyle P(x,y)$ a polynomial in the variables $x,y$.   For example, $\displaystyle x^4$ or $\displaystyle x^3y^2 + 3xy + 1$.  Is there a general method which allows us to evaluate the indefinite integral     $$ \int P(\sin x, \cos x) \text{d} x$$   What about the case when $\displaystyle P(x,y)$ is a rational function (i.e. a ratio of two polynomials)?   Example of a rational function: $\displaystyle \frac{x^2y + y^3}{x+y}$.    This is being asked in an effort to cut down on duplicates, see here:   and here: If we set $A$ and $B$. Assuming that there exist an injective map from $A$ to $B$ and an injective map from $B$ to $A$. How to prove that there is a bijection between $A$ and $B$. Making a WinForms TextBox behave like your browser's address bar When a C# WinForms textbox receives focus, I want it to behave like your browser's address bar.  To see what I mean, click in your web browser's address bar. You'll notice the following behavior:    Clicking in the textbox should select all the text if the textbox wasn't previously focused. Mouse down and drag in the textbox should select only the text I've highlighted with the mouse. If the textbox is already focused, clicking does not select all text. Focusing the textbox programmatically or via keyboard tabbing should select all text.   I want to do exactly this in WinForms.  FASTEST GUN ALERT: please read the following before answering! Thanks guys. :-)     Calling .SelectAll() during   the .Enter or .GotFocus events won't   work because if the user clicked the   textbox, the caret will be placed   where he clicked, thus deselecting all   text.      Calling .SelectAll() during the .Click event won't work because the user won't be able to select any text with the mouse; the .SelectAll() call will keep overwriting the user's text selection.      Calling BeginInvoke((Action)textbox.SelectAll) on focus/enter event enter doesn't work because it breaks rule #2 above, it will keep overriding the user's selection on focus. Applying MVT and IVT (?) to show something about f'''? (edit: actually, Taylor's Theorem using Lagrange remainder) I believe that the correct answer to this question will involve applying both the Mean Value Theorem and the Intermediate Value Theorem, perhaps several times.  However, I can't see how to proceed.  I went down what I thought were the typical paths and just reached dead ends.  Does someone maybe have a hint?  I think that with the appropriate nudge I should be able to solve this question.  If not, I'll edit and ask if someone knows how to solve the whole thing.  Here's the question:  Let $f: \mathbf R \to \mathbf R$ be such that $f$, $f'$, $f''$, and $f'''$ exist and are continuous on $\mathbf R$ and satisfying $f(-3)=-1$, $f(0)=0=f'(0)$, and $f(3)=8$.  Prove that there exists $\xi \in (-3, 3)$ such that $f'''(\xi) \ge 1$. I have already read        and many others   But I still have the following problem:   On one hand I've been told that if pure rotation takes place then the object goes on forever. This must imply no frictional force in any form acting on the body. On the second hand I've been told that during pure rotation(no external forces like wind) on a plane surface friction acts opposite to velocity of center of mass (accompanied by change of normal) and slows it down.     Both seem logical enough: The point of contact doesn't slip therefore no friction is required; So no retarding force and it must go on. Things don't go on forever; Friction must be present to slow it down.    So, which hand is correct? Or is there a third hand altogether? Note: the eventual outcome of this discussion involved dropping this particular off-topic reason, along with other changes. See:  &nbsp; &mdash;Shog     I was using the reason "demonstrate a minimal understanding" myself quite frequently, but the more I review, the more I have doubts about it and I think this reason can either be dropped entirely or at least rephrased, so I started to use "problems with code you've written must describe the specific problem" instead:     Questions asking for code must demonstrate a minimal understanding of the problem being solved.   So the poster has posted some description, maybe even a snippet of code and in his mind that already proves that he has that minimal understanding required. After all he described the problem and what he tried to solve. So telling him that he lacks that understanding is rather rude, and from the posters point of view doesn't even apply. What both version of the reason not emphasize is that a description of a problem is not various versions of     it doesn't work   but that we rather mean really specific details (see below). I can often see in the reopen review queue that the "improved" version just includes a more verbatim description, while what usually would be expected is some specific error message, a trace or a log, or whatever applies.  Then it continues with:     Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist   comparing it to:     problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.   Which says essentially the same, only in more detail.   So the "minimum understanding" reason is IMO a more rude version of the reason telling the user that an SSCCE is missing.  The intent of giving this reason is to tell the user that he needs to give exact details to be able to help him, so IMO a checklist would be much better. Something like:     Your question was closed because it may not provide enough details. Things you can do to improve your question to get an answer include:         Format the code in a way that makes it readable and easily understandable.   Provide the smallest working sample of code demonstrating the problem (link to SSCCE)   Include your input and output.   If applicable provide logs (i.e. Android debugging log, stack trace, etc.).   If applicable provide the exact error messages (compiler, etc.).      And something like this should be best included already in the banner that appears when a question is closed instead of being hidden in some pages you often enough have to actively looking for.  It might be helpful to adjust this, based on the tags or close reason, as I realize that I'm more focused on the programming area, and the above list may not apply to other areas of SO.  Update  Another thing I forgot to mention (but wanted to) is this:     Questions asking for code   Is IMO essentially an invitation of the type of questions     I have a problem, can you provide the solution? (with an optional please)   while     Questions concerning problems with code you've written   puts at least some emphasis on the fact that the poster has to put some effort himself in trying to solve the problem by providing the code which he used to attempt the solution. Find all entire functions $f(z)$ such that $|f(z)|=1$ for $|z|=1$ Quotient rings of Gaussian integers Async Await Handler Deadlock How to use fakeslant as slanted but not italic font with fontspec? Using fontspec with Luatex it is possible to create a fake slant and use that as italic should no italics be around:  \setmainfont[ AutoFakeSlant=0.15 ]             {FontName}   However, also if an italic version exist this faked slant will be used both for \itshape and \slshape. How can I keep using the shipped italic font defined by the ItalicFont= parameter to \setmainfont but use fake slant for \slshape? SFDX Pull fails because of AppMenu/AppSwitcher Passing a formatted NSDate