Usage of WeakHashMap? 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());
When would you use a WeakHashMap or a WeakReference? 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?
Why are angles dimensionless and quantities such as length not? So my friend asked me why angles are dimensionless, to which I replied that it's because they can be expressed as the ratio of two quantities -- lengths.   Ok so far, so good.  Then came the question: "In that sense even length is a ratio. Of length of given thing by length of 1 metre. So are lengths dimensionless?".   This confused me a bit, I didn't really have a good answer to give to that. His argument certainly seems to be valid, although I'm pretty sure I'm missing something crucial here. I want to know the general formula for $\sum_{n=0}^{m}nr^n$ for some constant r and how it is derived.  For example, when r = 2, the formula is given by: $\sum_{n=0}^{m}n2^n = 2(m2^m - 2^m +1)$ according to   Thanks! If $f:[a,b]\to \mathbb{R}$ is continuous and nonnegative and $\int_a^b{f}=0$, then $f(x)=0$ for all $x\in [a,b]$ Suppose that a function $f:[a,b]\to\mathbb{R}$ is continuous and nonnegative. Prove that if $\int_a^b{f}=0$, then $f(x)=0$ for all $x\in [a,b]$.   I've been trying to prove it using the extreme value theorem, continuity and the upper and lower sums but can't come up with something tight enough. More specifically, I've been trying to relate $|f(x)-f(t)|&lt;\epsilon$ to the sum of $M_k-m_k(x_k-x_{k-1})$ I am writing a small KOMA-Script scrartcl document with multiple sections. In the table of contents, LaTeX fills the current line with dots between the end of the section name and the page number. Is there any way to customize this behavior? I would like to reduce the space between the single dots (i.e. use more dots in the same space). Can someone give me a hint how to the irreducibility of $X^{p-1} + \cdots + X+1$, where $p$ is a prime, in $\mathbb{Z}[X]$ ?    Our professor gave us already one, namely to substitute $X$ with $X+1$, but I couldn't make much of that. What would be the best way to calculate someone's age in years, months, and days in T-SQL (SQL Server 2000)?  The datediff function doesn't handle year boundaries well, plus getting the months and days separate will be a bear.  I know I can do it on the client side relatively easily, but I'd like to have it done in my . Limit $\lim_{x \to \infty}{\sin{\sqrt{x+1}}-\sin{\sqrt{x}}}$ I want to compute $$\lim_{x \to \infty}{\sin{\sqrt{x+1}}-\sin{\sqrt{x}}}.$$  Is it OK how I want to do?    $$\sin{\sqrt{x+1}}-\sin{\sqrt{x}}=2\sin{\frac{\sqrt{x+1}-\sqrt{x}}{2}}\cos{\frac{\sqrt{x+1}+\sqrt{x}}{2}}=2\sin{\frac{1}{2(\sqrt{x+1}+\sqrt{x})}}\cos{\frac{\sqrt{x+1}+\sqrt{x}}{2}}$$  I'm not surem but I want to say that $$|\cos \frac{\sqrt{x+1}-\sqrt{x}}{2}| \leq 1$$ $$\sin{\frac{1}{2(\sqrt{x+1}+\sqrt{x})}} \to 0 \mbox{ when } x \to \infty$$ So the limit is $0$ ?  I thinks is not because  if I say that $ \displaystyle|\sin{\frac{1}{2(\sqrt{x+1}+\sqrt{x})}}| \leq 1$ I will obtain that another limit than $0$.   Thanks :) How to drive multiple LEDs from a Li-ion battery (with varying voltage)? How to set the fully qualified hostname on CentOS 7.0? How do I set the fully qualified hostname on CentOS 7.0?  I have seen a few posts online for example using:  $ sudo hostnamectl set-hostname nodename.domainname   However, running domainname returns nothing:  $ domainname (none)   Also:  $ hostname nodename.domainname   However,  $ hostname -f hostname: Name or service not known $ hostname -d hostname: Name or service not known   Some debug output:  $ cat /etc/hostname nodename.domainname  $ grep ^hosts /etc/nsswitch.conf hosts:      files dns What happens if I use RAM of a faster speed than the CPU supports? Dual monitor setup, why does NVidia 340 Prime only detect one monitor? I am very new to cryptography (so be kind), but I have a question that may seem silly.   If the one-time pad is the perfect cipher and impossible to crack, why would the following algorithm not be one of the strongest:  To encrypt:   generate a random bit array using a pseudo number generator with the key as the seed  The generated bit array is the size of the data use a simple XOR to encrypt using the generated bit array   To decrypt:   pseudo-random number generator will generate the same bit array with the same seed (the key) generate bit array the same size of the encrypted data run XOR on encrypted data using bit array that's generated   This is very simplified, but you can imagine how for larger encryption you could break down the data into blocks, and in order to ensure that the block bit arrays are random a new seed for each can be derived from the key. So, if $f(k)$ is the pseudo random number generator, and b is the block number, you can encrypt each block with $f(k+b)$. ($k$ is key)   Instead of using a pseudo-random number generator, you could use some hash algorithm to generate the pad.    (assuming you can use equivalently strong keys) would this not be a very strong cipher method? Perhaps it may be strong and heavy on memory since the pad needs to be the size of the data. So during encryption and decryption you need to generate a pad that's equivalent to the size of the data.   Is there a flaw in this algorithm, or would something like this not be practical and much slower than current standards? How do I unlock a SQLite database? sqlite&gt; DELETE FROM mails WHERE (`id` = 71); SQL error: database is locked   How do I unlock the database so this will work? Bound on integral implies bound on function I don't know how to prove this example. Let $y(t):\mathbb{R}^+\to \mathbb{R}$ be a nonincreasing function. Assume that there is a constant $A&gt;0$ such that \begin{equation} \int_{s}^{+\infty}y(t)dt \leq Ay(s), \quad 0\leq s&lt;+\infty \end{equation} Then $y(t)\leq y(0)e^{1-\frac{t}{A}}$, for all $t&gt;0$. Alt-Tab shows two application switchers on Unity I started to have problems with my Ubuntu application switcher (Alt +  Tab) this morning. When I press Alt +  Tab, not only one, but two application switchers show up. Last night I customized some stuff using the Unity Tweak Tool. I thought I didn't touch the application switcher. So now it looks like this: Combinations of selecting $n$ objects with $k$ different types Suppose that I am buying cakes for a party. There are $k$ different types and I intend to buy a total of $n$ cakes. How many different combinations of cakes could I possibly bring to the party? Execute managebean method from javascript onload event Why do I need 50 reputation to comment? What can I do instead? Alert on edit after a downvote What contributes to expanded company details being displayed in Google search results? For some results returned in Google Search, on the right side it displays the company details, logo, contact numbers, etc...   For example, see the following screenshot:    I'd like to know what contributes to this so that I can try to achieve it for my site too.