I have read other answers to try to find the solution but nothing clearly explains the issue.   Why should the following code block create a null pointer exception for currArraySize?      int biggestArraySize = 0;    int currArraySize = 0;     for(int i = 0 ; i &lt; myMap.keySet().size(); i++){         ArrayList&lt;String&gt; currList = new ArrayList&lt;String&gt;();        currList =  myMap.get(i);        currArraySize = currList.size();         if(currArraySize &gt; biggestArraySize){          biggestArraySize = currArraySize;          }      }       System.out.println(biggestArraySize);
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
How to use notify-send to notify users as root? #!/bin/bash export DISPLAY=:0 state=$(upower -i $(upower -e | grep BAT) | grep --color=never -E "state" ) stat=${state:25:32} batperct=$(upower -i $(upower -e | grep '/battery') | grep  -E "percentage:") bat=${batperct:24:26} intbat=$(echo $bat | cut -d'%' -f1) if [ "$intbat" -lt "15" -a "$stat" == "discharging" ]; then     notify-send 'battery low..! please plugin charger..... charge is only' "$intbat"     fi     The script runs fine when run as a normal user (bash script.sh). The desktop notification is displayed.  If I run it as root with sudo bash script.sh, the desktop notification is not displayed.  How can I use notify-send to notify users as root?  I am using Arch Linux. arithmetic progression of primes Prove that there is no arithmetic progression that consists only of primes.  A question that I've been set; I'm guessing it makes use of primes being written in the form 4k+1 and 4k+3? Not sure where to start.  Thanks. Generate uniformly distributed weights that sum to unity? It is common to use weights in applications like mixture modeling and to linearly combine basis functions. Weights $w_i$ must often obey $w_i ≥$ 0 and $\sum_{i} w_i=1$. I'd like to randomly choose a weight vector $\mathbf{w} = (w_1, w_2, …)$ from a uniform distribution of such vectors.  It may be tempting to use $w_i = \frac{\omega_i}{\sum_{j} \omega_j}$ where $\omega_i \sim$ U(0, 1), however as discussed in the comments below, the distribution of $\mathbf{w}$ is not uniform.  However, given the constraint $\sum_{i} w_i=1$, it seems that the underlying dimensionality of the problem is $n-1$, and that it should be possible to choose a $\mathbf{w}$ by choosing $n-1$ parameters according to some distribution and then computing the corresponding $\mathbf{w}$ from those parameters (because once $n-1$ of the weights are specified, the remaining weight is fully determined).  The problem appears to be similar to the  (but, rather than picking 3-vectors whose $ℓ_2$ norm is unity, I want to pick $n$-vectors whose $ℓ_1$ norm is unity).  Thanks! Does removing an application from Software Center do a remove or a purge When I remove an application already installed through the Software Center. Does it remove the app the same way as doing a purge to it (aptitude purge) or does it remove it like a "remove" (aptitude remove). The nautilus-open-terminal package adds a menu/right-click option to open a terminal in the current directory.  I want to change this from opening gnome-terminal to opening terminator. , however these instructions do not appear to be valid any more, and I can't find any place in the system settings where the default emulator can be changed.  I also tried:  $ sudo update-alternatives --config x-terminal-emulator   choosing  * 0            /usr/bin/terminator               50        auto mode   But this does not appear to have any effect. Any idea how I can get this to work? There are a few examples of pairs of words ending with -ee/-er like employee and employer or advisee and adviser. What I was curious about is if there was any rule that would describe the relationship of the objects in a pair like this and situations when it's appropriate to create a counterpart for a given word.   I'll give you an example. It's relatively common in the computer programming world to see the word dragee, which describes an object that is being dragged with a mouse. I understand that this is a relatively new word and could not be found in any dictionary (I've tried). Is that acceptable to make up words like this one or is it just bad English? Fastest way to try all passwords Suppose you have a computer with a password of length $k$ in an alphabet of $n$ letters.  You can write an arbitrarly long word and the computer will try all the subwords of $k$ consecutive letters. What is the smallest word that contains all combinations of $k$ letters as subword? (i.e. the fastest way to hack the computer :) )  The smallest word that contains $n^k$ subwords of size $k$ has length $k-1+n^k$ and based on some easy cases, we would like to prove that it is in fact possible to find a word of such length that contains all possible passwords. The problem can be translated into a problem in graph theory, by taking as vertices all words of length $k$.  We tried $k=2$, where you can prove the conjecture by induction. For $n=2$ and small $k$ it also works. Why is it possible to answer a question twice? I´m trying to model a race track using a bezier curve, but, when I add modifiers -> array -> curve I get this :    What should I check for to get the mesh following the curve correctly ? Thankyou Is it possible to disable the Super+ shortcuts that switch to apps in 12.04? How can I restrict various roles with limit in creating nodes of a particular content type Why Does the Transaction Log Keep Growing or Run Out of Space? Security of GCM if Implemented with Stream Cipher instead of Block Cipher Finding the Eclipse Version Number I am superimposing CGI over video footage, and have run into a problem in making materials for objects that act as 'shadow catchers'.  Essentially I want a shader that is shadeless—like an emitter—but catches shadows and light from other objects. This is so I can reconstruct objects in footage so other objects in the scene interact convincingly with them.  Here's an overcomplicated diagram to illustrate my point:   (In this particular scenario, the problem could be glossed over by using RGB curves, but that is definitely not the case with more complicated scenes)  Isn't this a common situation? How to the real guys do it? Thank you.  (I am welcome suggestions of other ways of doing this.) What type of path in shebang is more preferable? Why is it that we have to use the gerund form for the first example? I have been told that it is not grammatical to use the infinitive form.  For some verbs, it's okay:     I wanted to study English.   I had to study English.   I needed to study English.   I tried to study English.   I traveled to study English.   But, for some verbs, it's incorrect:     I ended up to study English.     Why is that the case? Can I embed a custom font in an iPhone application? I would like to have an app include a custom font for rendering text, load it, and then use it with standard UIKit elements like UILabel. Is this possible? Why won't my villagers breed I have created the following structure. The intention is to create fairly compact houses for villager breeding.   This is a section of the houses.   I have 2 of these structures, which would resolve to 28 doors and 4 other types of houses meaning I have 32 houses in total. healed healed 3 villager zombies and locked them inside a small house. One of them sometimes shows hearts, but they won't breed.   I am playing vanilla Minecraft 1.8. The doors are spruce.  What is wrong with these houses? Is there something wrong with spruce doors or half slab roofs? Do I cast the result of malloc?