okay so I am a beginner at java and I am implementing a class which stores an array and sorts it using bubble sort.  import java.io.*; public class Array {     private int array[];     private int n;     private BufferedReader br;     public Array() throws IOException     {         System.out.print("Enter the size of the array : ");         br=(new BufferedReader(new InputStreamReader(System.in)));         n = Integer.parseInt(br.readLine());         System.out.println("Enter "+ n +" integers");         for(int i=0;i&lt;n;i++)         {              array[i]=Integer.parseInt(br.readLine());         }      }     public void showArray()     {         int i;         for (i=0; i&lt;n;i++)         {             System.out.print(array[i]+"  ");         }     }     public void bubbleSort()     {         int max,last,i,j;         last = n;         for(i = 0; i&lt;n ; i++)         {             max=0;             for(j=0; j&lt;last; j++)             {                 max = (array[max]&gt;array[j]) ? max : j ;              }             j = array[last];             array[last] = array[max];             array[max] = j;             last--;         }     }     public static void main(String [] args) throws IOException     {             Array a1 = new Array();             System.out.println("Unsorted Array : ");             a1.showArray();             System.out.println("Sorted Array : ");             a1.bubbleSort();             a1.showArray();     } }   so when I run it it gives the error :  shubham@shubham-Inspiron-3542:~$ java Array Enter the size of the array : 4 Enter 4 integers 11 9 7 16 4 Exception in thread "main" java.lang.NumberFormatException: For input string: "11 9 7 16 4"     at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)     at java.lang.Integer.parseInt(Integer.java:580)     at java.lang.Integer.parseInt(Integer.java:615)     at Array.&lt;init&gt;(Array.java:16)     at Array.main(Array.java:48)   I am totally not getting what's the issue. What I can guess is there is some issue while parsing the input stream. edit: when I press Enter after an input I get this :  shubham@shubham-Inspiron-3542:~$ java Array Enter the size of the array : 5 Enter 5 integers 22 Exception in thread "main" java.lang.NullPointerException     at Array.&lt;init&gt;(Array.java:16)     at Array.main(Array.java:48)   edit 2: Splitting the input stream gets rid of NumberFormatException error but NullPointerException error is still there
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?
Is it possible to get the progress of an XMLHttpRequest (bytes uploaded, bytes downloaded)?   This would be useful to show a progress bar when the user is uploading a large file. The standard API doesn't seem to support it, but maybe there's some non-standard extension in any of the browsers out there? It seems like a pretty obvious feature to have after all, since the client knows how many bytes were uploaded/downloaded.  note: I'm aware of the "poll the server for progress" alternative (it's what I'm doing right now). the main problem with this (other than the complicated server-side code) is that typically, while uploading a big file, the user's connection is completely hosed, because most ISPs offer poor upstream. So making extra requests is not as responsive as I'd hoped. I was hoping there'd be a way (maybe non-standard) to get this information, which the browser has at all times. This is problem #6 from Section 1.2 of Ash's Real Variables With Basic Metric Space Topology.   I am asked to show that it is impossible to list the rational numbers in increasing order.   While I know it is possible to list a finite subset of the rational numbers in increasing order, I was wondering if the reason for the impossibility in this case is because there is no least element of $\mathbb{Q}$?   I mean, it's possible to impose an ordering on $\mathbb{Q}$ (correct me if I'm wrong, but it seems possible to compare any two rationals).  But the set $\mathbb{Q}$ is of course, a subset of itself, and the Well-Ordering Principle says that a set $S$ is Well-Ordered only if any subset of $S$ contains a minimal element. Since $\mathbb{Q}$ does not contain a minimal element, it does not appear that it is a Well-Ordered set.   Is this the correct idea as to why it's impossible? If not, could somebody explain to me what the correct idea is and a strategy for proving it?  Thank you ahead of time. Consider the following piece of Markdown code:  This is some regular text.      &gt;&gt;&gt; def factorial(n):     ...     return 1 if n &lt; 2 else n * factorial(n - 1)     ...   * This is a list item.      &gt;&gt;&gt; def factorial(n):     ...     return 1 if n &lt; 2 else n * factorial(n - 1)     ...    Notice that the second code block is preceded by a list item.   Why is the factorial code not properly formatted under these circumstances? To demonstrate the problem, I'll insert the Markdown code show above:    This is some regular text.  &gt;&gt;&gt; def factorial(n): ...     return 1 if n &lt; 2 else n * factorial(n - 1) ...     This is a list item                 def factorial(n):       ...     return 1 if n &lt; 2 else n * factorial(n - 1)       ...               This applies to numbered as well as unnumbered lists. Which metric to use to evaluate highly imbalance classification model performance The Center of $\operatorname{GL}(n,k)$ The given question:  Let $k$ be a ﬁeld and $n \in \mathbb{N}$. Show that the centre of $\operatorname{GL}(n, k)$ is $\lbrace\lambda I\mid λ ∈ k^∗\rbrace$.  I have spent a while trying to prove this and have succeeded if $ k \subseteq \mathbb{R}$. So I imagine there is a nicer way to go about this. I have seen people saying take matrices where every element except one is zero in proving similar results but such matrices are not in $\operatorname{GL}(n,k)$ as they are not invertible.  What I have done.  I have said let $B \in$ Center then $B$ commutes with everything in $\operatorname{GL}(n,k)$. So take a permutation matrix, $P$ which swaps rows $i,j$ $P \neq I$. From this you can deduce that $B^T = B$ and that $B_{ii} = B_{jj}$. We can use the fact that $B$ is symmetric to find an orthogonal diagonalisation of $B$ by the spectral theorem.  This gives $QBQ^T = D \rightarrow B=D$. And as $B_{ii} = B_{jj}$ we can say $B = k * I$.   But the spectral theorem requires $B$ to be a real matrix.   How do I prove this for a general $k$?. I am unable to find the bias of the sample variance estimator in this problem. Unfortunately I keep coming up with   Question: Suppose that the true linear model is   $y = X_1\beta_1 + X_2\beta_2 + e$,   where $e \sim MVN(0,\sigma^2 I)$, $X_1: N \times p_1, \beta_1: p_1 \times 1, X_2: N \times p_2, \beta_2: p_2 \times 1$. But we wrongly fit the model  $y = X_1\beta_1+e$ and calculate the estimators of $\beta_1$ and $\sigma^2$ as:  $\hat{\beta}_1 = (X_1'X_1)^{-1}X_1'y$,  $s^2 = \large \frac{y'[I-X_1(X_1'X_1)^{-1}X_1']y}{N-p_1}$.  (a) Show that, in general, $\hat{\beta}_1$ is a biased estimator with  Bias$(\hat{\beta}_1) = (X_1'X_1)^{-1}X_1'X_2\hat{\beta}_2$  Under what condition on $X_1$ and $X_2$ is $\hat{\beta}_1$ unbiased?  (b) Show that, in general, $s^2$ is a biased estimator with   Bias$(s^2) = \frac{1}{N-p_1}\beta_2'X_2'[I-X_1(X_1'X_1)^{-1}X_1']X_2\beta_2$  Is the bias positive or negative? Under what condition on $\beta_2$ is $s^2$ unbiased?  Attempt:  For part (a):  Bias$(\hat{\beta}_1) = E((X_1'X_1)^{-1}X_1'y - \beta_1)$  $\hspace{15mm}= (X_1'X_1)^{-1}X_1'E(y) - \beta_1$  $\hspace{15mm}= (X_1'X_1)^{-1}X_1'(X_1\beta_1 + X_2\beta_2) - \beta_1$  $\hspace{15mm}= (X_1'X_1)^{-1}X_1'X_1\beta_1 + (X_1'X_1)^{-1}X_1'X_2\beta_2) - \beta_1$  $\hspace{15mm}= I\beta_1 + (X_1'X_1)^{-1}X_1'X_2\beta_2 - \beta_1$  $\hspace{15mm}= \beta_1 + (X_1'X_1)^{-1}X_1'X_2\beta_2 - \beta_1$  $\hspace{15mm}= (X_1'X_1)^{-1}X_1'X_2\beta_2$  If $X_1$ and $X_2$ are orthogonal, then $\hat{\beta}_1$ is unbiased.  For part (b), I am unable to figure out how to derive:  Bias$(s^2) = \frac{1}{N-p_1}\beta_2'X_2'[I-X_1(X_1'X_1)^{-1}X_1']X_2\beta_2$  I can get   $\frac{1}{N-p_1}\beta_1'X_1'+\beta_2'X_2'[I-X_1(X_1'X_1)^{-1}X_1']X_1\beta_1+X_2\beta_2$  after taking the expectation of y on both sides.   Any help would be much appreciated. I'm buying a bus ticket to get to Boston 23 hours before my flight to ensure I reach my departure airport on time.  If I didn't arrange bus transport well in advance, what legal remedies would I have if a delayed bus caused me to miss my flight? When to use \LetLtxMacro? Frequently I see users redefine macros using (for example)  \let\oldmacro\macro% Store \macro in \oldmacro \renewcommand{\macro}{%   % ...redefined \macro   \oldmacro% }   and other times they use  \usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro \LetLtxMacro{\oldmacro}{\macro}% Store \macro in \oldmacro \renewcommand{\macro}{%    % ...redefined \macro   \oldmacro% }   Why would one use \LetLtxMacro when \let works just as well? Or, more specifically, when would one use \LetLtxMacro and/or why? What makes you lose the Field Upgrade Score? When playing in a squad, you can get "Field Upgrades". However, sometimes when I die, it tells me that I have lost the "Field Upgrade Score".   Where can I see this score and what are the events that make me lose it? How to get battery status? How do I get the battery status on an iPhone? Do fontsize environments exist? Without any doubt there are fontsize switches in the form of control sequences (described  for instance.) But, from time to time I ran into code examples where environment versions of those were used, e.g. \begin{small}...\end{small}. After testing those successfully I began to incorporate them into my TeX vocabulary.  A few days ago @GonzaloMedina commented on one of my answers that those environments do not exists and constructions relying on them work by pure coincidence. Then I tried to find out more about those ominous environments. Ominous because they don't seem to be somehow documentated. (The only thing I found that tried to explain them in a somehow systematical manner was some Wikibooks resource.)  Are these environments real or not? Neutrino Oscillations and Conservation of Momentum I would like to better understand how neutrino oscillations are consistent with conservation of momentum because I'm encountering some conceptual difficulties when thinking about it. I do have a background in standard QM but only rudimentary knowledge of particle physics.   If the velocity expectation value of a neutrino in transit is constant, then it would appear to me that conservation of momentum could be violated when the flavor eigenstate at the location of the neutrino source is different from that at the location of the interaction, since they are associated with different masses.  For this reason I would think that the velocity expectation value changes in transit (for instance, in such a way to keep the momentum expectation value constant as the neutrino oscillates), but then it seems to me that the neutrino is in effect "accelerating" without a "force" acting on it (of course, since the momentum expectation value is presumed constant, there may not be a real problem here, but it still seems strange).   Any comments? Short circuit or disconnect to bypass a compressor Two  have been announced in LoL.  They have an ability that makes them be able to recall together.                                  What are the limits to this ability? Can the 'non-recaller' jump in at the last second and get some kind of instant recall?  Can somebody with the setup to get on PBE test it and tell us what are the limitations of this ability? Breitbart today:   What is the source for the term nothing-burger? How do you make a deep copy of an object? It's a bit difficult to implement a deep object copy function. What steps you take to ensure the original object and the cloned one share no reference? Escape velocity from Earth Is there a formal spelling for the English letter names? How can I get maximum DoF with no distance markers? I am aware of what hyperfocal distance is and the general principles behind it. However, most of the tutorials I have seen and read regarding it make use of lenses with focus distance indicators. Unfortunately, neither of my lenses (Nikkor 18-55mm &amp; 35mm f1.8) have indicators.  I have read that you can 'cheat' and simply focus a third of the way into the shot (which I have done previously simply by spot-focusing on the lowest focus point in my VF). I also assume you could pace out the distance and note an object to focus on when you get back to the camera (though that might be easier said than done).  Does anyone have any suggestions on how to achieve maximum sharpness from front to back without focus distance markers. A new lens is not an option; global economic crisis and all that! Is there a way to use the formatter that comes with eclipse, outside of eclipse?  I would like to format some java files using my formatter.xml file that I have configured using eclipse.  Does anyone have any code examples that would allow me to do this?  I would also like to use this standalone, so the specific jars that are used would be nice.