I wrote a code for keeping record of indices even after sorting but it is showing me null pointer exception.I read other threads on same topic but still couldn't find.  import java.io.*; import java.util.*;  public class Solution { class Order{     public int index;     public int sum;      public void setIndex(int index){         this.index = index;     }     public void setSum(int sum){         this.sum = sum;     }     public int getSum(){         return this.sum;     }     public int getIndex(){         return this.index;     } } public static void main(String[] args) {     /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */     Scanner sc  = new Scanner(System.in);     int N = sc.nextInt();     Order array[] = new Order[N];     int index = 0;     int sum = 0;     while(index&lt;N){         int input1 = sc.nextInt();         int input2 = sc.nextInt();         //line 32         array[index].setIndex(index);         array[index].setSum(input1+input2);         index++;     }     ArrayList&lt;Order&gt; list = new ArrayList&lt;Order&gt;(Arrays.asList(array));      Collections.sort(list, new Comparator&lt;Order&gt;(){         @Override         public int compare(Order o1, Order o2){             return(Integer.compare(o1.getSum(), o2.getSum()));         }     });      System.out.println(list);  } }   error is like this :  Exception in thread "main" java.lang.NullPointerException at Solution.main(Solution.java:32)   I am passing i, still null pointer why?
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 are dashes implemented in TeX? How does LaTeX implement the differences between the dashes?  -, --, and --- all print different dashes, but - is not an active character: it has catcode 12, the same as digits like 2. The well-known fable of an astronaut sending signals out to an external observer while falling toward an event horizon states that the time lapse between such signals becomes greater even if in the astronaut sends them out periodically (as judged in his inertial frame). When viewed from earth and weighing time-dilation due to the gravitational field of the collapsing star, how is it possible that a black hole can form in finite time (for any external observer) if it takes an infinite amount of time to "see" events occurring at the event horizon? How do I create a script file for terminal commands? How to Expand , Resize "extended partition"? How can I expand/resize my extended partition (sda3) with unallocated free space to the left of it? I want this to be able to expand my / partition (sda5). "Thus" vs. "so" in formal English Make locking posts more granular bash - problems reading text file and printing line by line In the PGF/TikZ manual, sometimes I see the option right of=somenode instead of right=of somenode. They look very similar, but the effects are different.  The distance between nodes positioned with the latter option is boundary-to-boundary, as stated in the manual. However, with the first option, it seems that the distance is shorter. I couldn't find any explanation of the first option in the manual.  My question is: what is the difference between the two options? Is there any explanation in the manual that I missed? I found this question in a book.   How many terms of the Maclaurin expansion of $(1+x)^{82}$ are needed to guarantee finding a value of $1.1^{82}$ to an accuracy of $10^{-6}$?  This is how I tried to do it:  We want the Lagrange error to be less than $10^{-6}$:  $$R_{n}(0.1)&lt;10^{-6}$$  Now to find $R_{n}(0.1)$:  $$R_{n}(0.1)=\frac{f^{(n+1)}(0.1)\cdot0.1^{n+1}}{(n+1)!}$$  After writing the values of ${f^{(n+1)}}(x)$, I find a pattern and say that  $${f^{(n+1)}}(x)=\frac{82!}{(82-n)!}(1+x)^{82-n}$$  $${f^{(n+1)}}(0.1)=\frac{82!}{(82-n)!}(1.1)^{82-n}=\frac{82!(1.1)^{82-n}}{(82-n)!}$$  Now just substitute all of this back to $R_{n}(0.1)&lt;10^{-6}$:  $$\frac{\frac{82!(1.1)^{82-n}}{(82-n)!}\cdot0.1^{n+1}}{(n+1)!}&lt;10^{-6}$$  Great! Now I have an inequality that I can solve. I can't graph this so I just use trial and error (which seems like quite an intensive way to do it, so if anyone has a better way I'd love to know).  $$\frac{\frac{82!(1.1)^{82-n}}{(82-n)!}\cdot0.1^{n+1}}{(n+1)!}-10^{-6}&lt;0$$  This seems to work first for $n=28$. That means the highest power of $x$ that I need is 28, so the number of terms in the expansion needs to be $n+1=29$. But the book's answer is       30   What am I doing wrong here? I'm still quite new to the power series expansions so if there's anything unclear in my working, please let me know (also, as a side note, the book itself may be wrong, though that isn't very likely I'd assume). Elementary argument for conservation laws from symmetries *without* using the Lagrangian formalism It is well known from Noether's Theorem how from continuous symmetries in the Lagrangian one gets a conserved charge which corresponds to linear momentum, angular momentum for translational and rotational symmetries and others.  Is there any elementary argument for why linear or angular momentum specifically (and not other conserved quantities) are conserved which does not require knowledge of Lagrangians? By elementary I mean, "if this is not so, then this unreasonable thing occurs".   Of course, we can say "if we want our laws to be the same at a different point in space then linear conservation must be conserved", but can we derive mathematically the expression for the conserved quantity without using the Lagrangian?  I want to explain to a friend why they are conserved but he doesn't have the background to understand the Lagrangian formalism. I wanted to know how I could configure multi-touch gestures in Ubuntu. In windows I can do this using the synaptics driver software.  I have already used synclient to configure the taps, palmdetect, scroll, etc. But I'd also want gesture support. Is is even possible?  System-Info: Ubuntu 12.10, Synaptics clickpad How bug prioritization works in agile projects vs non agile When reporting a defect, we are setting the priority and severity of the defect. How this works with agile development? Is there any specific way ?  How bug prioritization works in agile projects vs non agile.?  Is there any other way of measuring the priority of a bug in agile projects? After lethal first strike damage to an indestructible creature, will it still do damage? If I were to attack with a 4/4 indestructible creature and it's blocked by a 4/2 creature with first strike, would my indestructible creature still attack during the second combat damage step, or would it just tap, not assigning any damage? How to measure supply currents ranging from 1μA to 10mA? Is there a general formula for solving 4th degree equations (quartic)? There is a general formula for solving quadratic equations, namely the Quadratic Formula:  $$ x = \frac{ -b \pm \sqrt{ b^2 - 4ac } }{ 2a } $$  For third degree equations of the form $ax^3+bx^2+cx+d=0$, there is a set of three equations: one for each root. Is there a general formula for solving equations of the following form? $$ ax^4 + bx^3 + cx^2 + dx + e = 0 $$ How about for higher degrees? If not, why not? There is no continuous injective function $f:\mathbb{R}^n\longrightarrow\mathbb{R}^m$ I have the following question, more general that   Let $U\subset\mathbb{R}^n$ be a domain. If $f:U\longrightarrow\mathbb{R}^m$  ($m&lt; n$) is a continuous function, how to prove that $f$ is not injective.  Any hint would be appreciated. Gerund preceded by a genitive? Is this sentence actually grammatical?     You know your having a rough day when kittens don't even make you smile.   The writer of this sentence may intend to mean you're instead of your but I'm just wondering if having a gerund preceded by a genitive is considered grammatical in this case.  If the sentence above is ungrammatical, why is this sentence grammatical?      He resents your being more popular than he is.   What's the difference between these two sentence that determines one to be grammatical and the other to be not?  This is how I analyze the two sentences and I can't see the difference:   "You know it when kittens don't even make you smile" for "it" = "your having a rough day" "He resents it" for "it" = "your being more popular than he is" I'm considering re-designing my personal website to promote my web services in my local area.  My issue is whether to do a one page website with a scroll-to navigation system. What effect does this have on SEO. As i understand it, you set stuff like h1's and meta description on specific page content. How does this work when all of your different content is on one page? Is it possible to scale up an image to increase the the pixel density? need to make salesforce app available in multiple language I want to make my appexchange app available in multiple language like Spanish, dutch etc. so that depend on the language of the user they can access the app.  Is it possible in any way..  any help will be appreciated.. Thanks