Java: sorting array of strings error I just started programming in java (yesterday as a metter of fact) and I'm messin' around trying to learn the basics. So I decided that I wanted to read a string, save the words in an array of strings and then sort that array and output it sorted. Here's the code for it:  package project2; import java.util.Scanner;  class First {public static void main(String args[]) {   Scanner scan=new Scanner(System.in);     Second obj=new Second(2,3);     String s; // the string     String word[]=new String[10]; // the array of strings     int n=0; // the number of elements in the array     System.out.print("String: ");     s=scan.nextLine();     System.out.printf("This is the string: %s\n", s);     for(String i : s.split("[,. ]") )         {word[n]=i;         n++;}      for(int j=0; j&lt;word.length;j++) //1      {for (int i=j+1 ; i&lt;word.length; i++)          {if(word[i].compareTo(word[j])&lt;0)              {String temp= word[j];               word[j]= word[i];                word[i]=temp;}}} //2       System.out.print("The sorted string is: ");     for(int i=0;i&lt;n;i++)         System.out.print(" "+word[i]);   }}   Now, when I try to run it for the input:      aa bb cc   I get the error:     Exception in thread "main" aa bb cc java.lang.NullPointerException    at   project2.First.main(First.java:20)   Now the error comes from within 1 and 2, but I can't figure out what causes the error.
What is a NullPointerException, and how do I fix it? 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?
Count where any 3 columns have values (not null) What is the best symbol to use for the d'Alembertian? Normally, most people use the symbol $\Box$ to represent the  (including the linked to Wikipedia page).  Recently I wanted to use \hat\Box and \tilde\Box, but they do not render very well.    What is the "best" way to create such symbols?    Aside: The above image is rendered using my local install of pdflatex: pdfTeX 3.1415926-1.40.10-2.2 (TeX Live 2009/Debian). The symbols seem to render fine on some online services: e.g. "" produces    from   \begin{align*} \Box &amp;= \sum_a \partial^a\partial_a \,, &amp; \hat\Box &amp;= \sum_a \mathcal{D}^a\mathcal{D}_a \end{align*} Appropriate statistical analysis to use How can I get free or trial ExactTarget instance How can I get free or trial ExactTarget instance. I need to do ExactTarget SAML2.0 Single Sign-On connector development, integration and testing. Is there any step by step documentation available so that I can work on ExactTarget SAML2.0 Single Sign-On ? I've heard a lot about the Undying Lands but I don't fully understand how they're different from Middle-earth and why only certain people/races are allowed to go there.  Can someone explain? Conditional formatting of an entire row based on multiple cells I'm trying to make a conditional formatting rule in Google Spreadsheet that would highlight a row green based on text in multiple cells.   If cells L2, M2, and N2 = APPROVED; and cell O2 = X; then row 2 = highlighted green. Why am I getting "size mismatch" errors from the Iceland mirror? After installing Ubuntu 12.04 (clean install) I fetch a bunch of program via synaptic (installed specially), all programs worked except Gimp 2.8. So I tried purging Gimp, install again (no luck). Checked broken packages and reinstalled them. When using the Software center I get this MSG:  Failed to fetch http://is.archive.ubuntu.com/ubuntu/pool/main/o/openexr/libopenexr6_1.6.1-4.1_amd64.deb Size mismatch   Tried also this:  sudo apt-get purge gimp* sudo add-apt-repository ppa:otto-kesselgulasch/gimp sudo apt-get update sudo apt-get install gimp   And get this MSG:  Failed to fetch http://is.archive.ubuntu.com/ubuntu/pool/main/o/openexr/libopenexr6_1.6.1-4.1_amd64.deb  Size mismatch E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?   I am wondering if the Icelandic Archive has an outdated version or something?   would really like to install Gimp 2.8 but Gimp 2.6 is OK to.   I am also wondering if I am doing something wrong? At what port did Lorance Effler born about 1787 in Germany come to the US? This picture is a part of a table i am using, the terms subcases are vertically written but i cant center them vertically also in the next columns terms like A, B, etc are also not vertically centered. I made this table using tabulary package a. My code is  \begin{table}[H]  \centering  \caption{Saturation Table}  \label{tab:5}%  \begin{tabulary}{1\linewidth}{J J J J J J J J J J J J J}  \toprule  &amp; \textbf{Method} &amp; \multicolumn{1}{c}{\textbf{Parameters}} &amp; \textbf{Step 0} &amp; \textbf{Step 1} &amp; \textbf{Step 2} &amp; \textbf{Step 3} &amp; \textbf{Step 4} &amp; \textbf{Step 5} &amp; \textbf{Step 6} &amp; \textbf{Step 7} &amp; \textbf{Step 8} &amp; \textbf{Step 9} \\  \midrule  \multirow{4}[4]{*}{\begin{sideways}\textbf{Subcase A}\end{sideways}} &amp;  \multirow{2}[2]{*}{\textbf{A}} &amp; \textbf{No} &amp; 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 &amp; \textbf{6} &amp; &amp; &amp; &amp; \\[1mm]  &amp; &amp; \textbf{Maximum Saturation {(\%)}} &amp; 1 &amp; 2 &amp; 3 &amp; 4 &amp; 4 &amp; \textbf{5} &amp; &amp; &amp; &amp; \\  \cmidrule{2-13} &amp; \multirow{2}[2]{*}{\textbf{B}} &amp; \textbf{No} &amp; 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 &amp; 6 &amp; 7 &amp; \textbf{8} &amp; &amp; \\[1mm]  &amp; &amp; \textbf{Maximum Saturation {(\%)}} &amp; 6 &amp; 6 &amp; 7 &amp; 8 &amp; 9 &amp; 9 &amp; 19 &amp; \textbf{8} &amp; &amp; \\  \bottomrule  \end{tabulary}%  \end{table}% How Can I prove (a+b) mod m = (a mod m) + (b mod m)) mod m? modular arithmetic  How Can I prove (a+b) mod m = (a mod m) + (b mod m)) mod m ? class C {   T a; public:   C(T a): a(a) {;} };   Is it legal? A topological space $X$ is simply connected if it is pathwise connected and each closed path $u : I = [0,1] \to X$ is path homotopic to the constant path at $x_0 = u(0) = u(1)$. Recall that  A closed path $u$ is one with $u(0) = u(1)$. A closed path will also be called a loop and we write $\mathcal L'(X)$ for the set of all loops in $X$. If we want to be more precise, we say $u$ is a loop based at $x_0 \in X$ provided $x_0 = u(0) = u(1)$. By  $\mathcal L'(X,x_0)$ we denote the set of all loops in $X$ which are based at $x_0$. Also note that each constant path is a loop.  Two paths  $u, v : I \to X$ with the same initial point $x_0 = u(0) = v(0)$ and the same terminal point $x_1 = u(1) = v(1)$ are path homotopic, $u \simeq_p v$, if there exists a  homotopy $H : I \times I \to X$ such that $H(t,0) = u(t)$ and $H(t,1) = v(t)$ for all $t$ and $H(0,s) = x_0, H(1,s) = x_1$ for all $s$ (such a homotopy $H$ is stationary on the boundary $\partial I = \{0,1\}$; it is called a path homotopy). It is well-known that $\simeq_p$  is an equivalence relation on the set $\mathcal P(X)$ of all paths in $X$. Clearly $\simeq_p$ restricts to an equivalence relation on $\mathcal L'(X)$ and to an equivalence relation on each $\mathcal L'(X,x_0)$.  The set of equivalence classes $\mathcal L'(X,x_0)/\simeq_p$ is nothing else than the fundamental group $\pi_1(X,x_0)$ with base point $x_0$.   Question: Find a list, as complete as possible, of properties characterizing topological spaces which are simply connected. Each of these properties can then be taken as an alternative definition of simply connected. Note that many questions in this forum deal with aspects of simple connectedness. The answer to the present question will hopefully cover most of them. Optional argument after splat argument Ready to use leaderboard service. Is any? I'm looking for ready to use thirdparty leaderboard service where player's achivementes and scores can be placed. I'd intagrate it into my game to allow players push scores and locate themselves in the tables of tops. It would be nice whether anybody experienced share some points with me. How to copy all files from a directory to a remote directory using scp? How can I access google.com outside the US? I live in the UK, and whenever I visit google.com I am redirected to google.co.uk, but I want to see my website's rankings on the US version (I presume the results are different). Is there a way to do this? How much does it cost to have a custom ASIC made? Combining the entries of two lists Only actions taken are displayed on question while checking the history of Low Quality Posts review On Ask Ubuntu, when I try to view my Low Quality Posts review history and click on the action taken on questions, I can only see the actions taken and no preview of the question.   :    The question still exists on the site:   It seems question review history page is missing this HTML class:  &lt;div class="reviewable-post reviewable-post-post_id"&gt;   On the other hand, everything is working fine for answers. prove $\lim_{n\to\infty}{\frac{a^n}{n!}}=0$ I have the proof but i don't understand one part. The proof (for $a&gt;1$) goes as follows:  there exists $k \in N$ such that$a&lt;k, \frac{a}{k}&lt;1$ and since $\frac{a}{k+i}&lt;\frac{a}{k}, i \in N$ $$\frac{a^n}{n!}=\frac{a}{1} \cdot \frac{a}{2} \cdot...\cdot\frac{a}{k}\cdot\frac{a}{k+1}\cdot...\cdot\frac{a}{n}&lt;\frac{a^k}{k!}(\frac{a}{k})^{n-k}=\frac{a^k}{k!}\cdot \frac{a^na^{-k}}{k^nk^{-k}}$$  $$0&lt;\frac{a^n}{n!}&lt;\frac{k^k}{k!}(\frac{a}{k})^n$$  then $$0 \leq \lim_{n\to\infty}{\frac{a^n}{n!}}\le\frac{k^k}{k!}\lim_{n\to\infty}{(\frac{a}{k})^n}$$  Now, the part I don't understand is in the expansion of $\frac{a^n}{n!}$. How does one come with $&lt;\frac{a^k}{k!}(\frac{a}{k})^{n-k}$ part, to be more precise, how does one come up with $(\frac{a}{k})^{n-k}$ part of the inequality?