all. I'm trying to get a value from a document, that looks like this:  {       "id" : player:(some number)",       "name" : "Martinez, Javi",       "type" : "midfielder",       "jersey_number" : 8,       "position" : "Central defender"     }   I have players in an ArrayList&lt;Document&gt; playersOnPitchHome and want to find one with a particular "jersey_number"  My code (below), however, is giving me a NulPointerException in the row I've highlighted with the //here comment. As far as I understand, the exception is not occuring due to me accessing playersOnPitchHome  The Code:  Document player = playersOnPitchHome.get(0);        int i;        for (i=0; i&lt;playersOnPitchHome.size(); i++) {            player = playersOnPitchHome.get(i);            int numberTemp = (int) player.get("jersey_number"); //here            if (numberTemp == playerNumber) break;            if (i==(playersOnPitchHome.size()-1) &amp;&amp; numberTemp != playerNumber) {               throw new Exception ("there is no such player on the pitch");           }      }   Thank you in advance.
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?
SSH login with clear text password as a parameter? I need to login to a user that I've created on a remote host running Ubuntu. I can't use an ssh key because the ssh login will happen from a bash script ran within a server that I won't have access to (think continuous integration server like Bamboo).   I understand this isn't an ideal practice, but I want to either set the remote host to not ask for the password or be able to login with something like ssh --passsword foobar user@host, kind of like MySQL allows you to do for logins.   I'm not finding this in man ssh and  I'm open to any alternatives to getting around this issue. Though tangentially related to another post on MathOverflow (), the questions below are mainly out of curiosity. They may be very-well known ones with very well-known answers, but...    Suppose $\Sigma$ is a sigma-algebra over a set, $X$. For any given topology, $\tau$, on $X$ denote by $\mathfrak{B}_X(\tau)$ the Borel algebra over $X$ generated by $\tau$.     Question 1. Does there exist a topology, $\tau$, on $X$ such that $\Sigma = \mathfrak{B}_X(\tau)$?   If the answer to the previous question is affirmative, it makes sense to ask for the following too:     Question 2. Denote by ${\frak{T}}_X(\Sigma)$ the family of all topologies $\tau$ on $X$ such that $\Sigma = \mathfrak{B}_X(\tau)$ and let $\tau_X(\Sigma) := \bigcap_{\tau \in {\frak{T}}_X(\Sigma)} \tau$. Is $\Sigma = \mathfrak{B}_X({\frak{T}}_X(\Sigma))$?   Updates. Q2 was answered in the negative by Mike (). Add new alias to Gmail without SMTP (forwarding-only address) I used to be able to go to Accounts and Import → Add another email address you own and add an email account that's only a forwarding address. That is, it's not a mailbox and I don't have SMTP access to it.  Gmail would send me a confirmation email to that address, I'd confirm it's mine, and done. Now it only gives me the option to add SMTP credentials.  Did they stop supporting the previous method? Is there any other way I can get that option back? Pretty much every application I use in full-screen (including Firefox, MacVim and the Terminal) have tabs on the top of the screen.  The problem is, when I move my mouse to reach the tabs I'll often accidentally touch the top of the screen, bringing in the OS menu OVER the tabs:    Is there any way to change this behavior? I'd prefer it if the menu bar would stay hidden when I'm using a full-screen app, even if my mouse does touch the top of the screen. I have modeled a simple pocket watch in Blender. Every time I import it into Unity3D, regardless of whether I export it from Blender as an FBX or 3ds file, it always comes out missing faces! Why is this happening? I have never had problems importing models into Unity3D like this before.  Blender Screenshot    Unity Screenshots     It seems to me that different faces appear when I rotate it differently. How can I prevent this? Thanks! I want to know if this is grammatically correct " How long would the conference be for?". Lie algebra and tangent space at the identity are isomorphic Define the Lie algebra $\mathfrak{g}$ of a Lie group G to be the set of all left-invariant vector fields of $G$. I want to prove that   $$          f: \mathfrak{g} \rightarrow T_eG \\              X \mapsto X(e) $$ is a linear isomorphism.  The only thing that I have left to prove is surjectivity.Letting $v\in T_eG$, we set $X\in \mathcal{X}(G)$ such that $\forall x\in G,\,X(x)=L_{x_{*,e}}(v)$ (I still have to show that such an $X$ is indeed a vector field on $G$). We get that  $$ f(X)=X(e)=L_{e_{*,e}}(v)=v $$  where the last equality holds because  $$       L_{e_{*,e}}(v)f = v(f \circ L_e) = v(f \circ id_G) = v(f) $$ for any $f\in C^\infty(G)$. (I am thinking of the tangent vectors as derivations).  Now all we have left to do is prove that such an $X$ is left-invariant, and it is therefore an element of $\mathfrak{g}$, but I do not know how. I tried to prove that  $$            \forall f\in C^\infty(G),\, L_{{x}_*,y}(X(y))f=X(L_x(y))f $$ but with no success. How can I write % into a file? How can I write % into an auxiliary file? % will not work, because LaTeX thinks that I start a comment with it (in the main file, not in the auxiliary file!), and \% will write \% into the file. How can it be accomplished?   \documentclass{article} \begin{document} \newwrite\outfile \immediate\openout\outfile=example.dat \immediate\write\outfile{%}% will not work, of course, but neither \% \immediate\closeout\outfile \end{document} How to deserialize a JSON String to Apex Why didn't Doc remember Marty's outfit? In Back to the Future 3, Doc (from 1955) sends Marty back in time wearing a cowboy outfit.  But then, Doc (from 1885) doesn't remember that it was him who offered this outfit to Marty.   Does this mean there are two different Docs (from differing timelines) or is it the same Doc but he somehow forgot the outfit. I’ve always understood that the phrase two weeks usually turns into two weeks’ when used as a modifier as in   I’m giving my two weeks’ notice.  I get two weeks’ vacation. (“two weeks’ holiday” for Brits)   with an apostrophe on the word weeks’, indicating that the vacation “belongs” to the weeks.   One way to explain this is the phrase “two weeks of vacation” being contracted to “two weeks’ vacation” – the vacation is “of” the weeks; that is, it is possessed by them.  But I’ve seen a lot of people omit the apostrophe in casual writing, and thinking about it, it seems plausible that the noun vacation would be plainly modified by the adjectival phrase two weeks.  But on the other hand, shouldn’t adjectival phrases be hypenated, namely two-weeks vacation?  Yet that seems wrong, too: the hyphenate should be singular, two-week vacation (like two-tone shoes) because .   touches on this (and references a good ) but doesn’t explain why the plural must be possessive in this case.   suggests that two weeks might be adverbial rather than adjectival, and thus resists being used attributively. But that still doesn’t quite explain this particular muddle of pluralization, possession, and attribution.  Given all this, why should “two weeks vacation” be written “two weeks’ vacation” with a possessive apostrophe? If a,b,c,d are positive integers with a sum of 63, what is the maximum value of ab + bc + cd ? (By using calculus to solve it)) If $a,b,c,d$ are positive integers with    $$a+b+c+d=63,$$   what is the maximum value of $$ab+bc+cd?$$   I treated this as an optimization problem and tried to solve it but I did not make any progress. A twice differentiable function $f$ satisfies $f′′(x)+f(x)=−xg(x)f′(x)$, $\forall x\ge 0$. Consider $f\in C^2$ so that $$f''(x)+f(x)=-x\,g(x)f'(x), \ \forall x\ge0 $$ where $g(x)\ge 0$. Then ($\forall x\ge 0$)         (A) $f(x)^2+f'(x)^2$ is non-increasing,   (B) $f(x)^2&lt;3f(0)^2+(2f'(0))^2$,   (C) $|f(x)|\le\alpha$, where $\alpha$ is a fixed real constant.   (D) $\lim_{x\to\infty} f(x)\sin\left(\dfrac{1}{x}\right)$ exists.        Answer Given: (A),(B),(C),(D)  What I have tried : I differentiated option (A) and then with the help of the given equation in the question I was able to show that  it is less than zero . Hence I was able to infer that option (A) is correct .   Now coming to option (B).  I assumed the function in option (A) to be $h(x)$.   $$ h(x) = f(x)^2 + f'(x)^2 $$  Since $h'(x)&lt;0$ ,therefore $h(x)$ is a decreasing function   hence for all $x\ge 0$  $h(x)&lt; h(0)$  which implies $(f(x))^2 + (f'(x))^2&lt;(f(0))^2 + (f'(0))^2$  From the above expression we can get the second option .   Is my method correct ?. If not , please show the right method .  I am unable to get the the 3rd and 4th option . How many edges does an undirected tree with $n$ nodes have? Is posting someone's comment as an answer okay? I came across  and at the time there were no suggested answers. After reading Mark Hubbart's comment (at the time with four upvotes), which was the correct answer, and seeing that it had been over 30 minutes since his comment, I figured I would provide that answer in my own words, which I did. My answer is longer, and I think more rounded and more useful, but the core of the answer came from the comment. I have no idea if I'd have thought up the answer on my own--a definite maybe to that.  Now had I tried to be "honorable" or something, such as instead of answering, suggesting to the commenter that he make his comment an answer, I would only have accomplished giving away easy rep to some other user not as into gratuitous self-denial.  The commenter had merely to enter his comment into an answer box instead of a comment box! It was his choice! Whether he was too lazy or didn't think his answer worthwhile or some other reason is not my responsibility. Must I bend over backward to help him earn points that he so carelessly left lying around for another person to take? It just took a tiny bit of non-laziness on my part to get my text typed into the box that would reward me instead of the box that wouldn't.  If my perspective is incorrect and the community would rather see such answers-as-comments rewarded and supported, I will gladly accept that. In the meantime, I just want to shake off the tiny bit of guilt my overly-nice and overly-concerned-with-propriety self is feeling. :) I'm new to data mining and I'm trying to train a decision tree against a data set which is highly unbalanced. However, I'm having problems with poor predictive accuracy.  The data consists of students studying courses, and the class variable is the course status which has two values - Withdrawn or Current.   Age Ethnicity Gender Course  ... Course Status   In the data set there are many more instances which are Current than Withdrawn. Withdrawn instances only accounting for 2% of the total instances.  I want to be able to build a model which can predict the probability that a person will withdraw in the future. However when testing the model against the training data, the accuracy of the model is terrible.  I've had similar issues with decision trees where the data is dominated by one or two classes.  What approach can I use to solve this problem and build a more accurate classifier? Reason for the discreteness arising in quantum mechanics? What is the most essential reason that actually leads to the quantization. I am reading the book on quantum mechanics by Griffiths. The quanta in the infinite potential well for e.g. arise due to the boundary conditions, and the quanta in harmonic oscillator arise due to the commutation relations of the ladder operators, which give energy eigenvalues differing by a multiple of $\hbar$. But what actually is the reason for the discreteness in quantum theory? Which postulate is responsible for that. I tried going backwards, but for me it somehow seems to come magically out of the mathematics. Error 1962: no operating system found after installing 12.04 (Lenovo ThinkCentre) I just installed a fresh copy of 12.04 on a new Lenovo ThinkCentere from a USB drive, and when I restarted after installation, the boot sequence didn't find the OS. Instead I got the 'no operating system found' error. When I started Ubuntu from the USB, I could see the HDD and that it had all the installed files. I just couldn't boot into it. It appeared that GRUB was not at the right place... or that there was something funky with the MBR. What is the simplest way to fix these sorts of errors?  Thank you,  EDIT: It appears the problem might have to do with UEFI and GRUB... Simplify the expression $\binom{n}{0}+\binom{n+1}{1}+\binom{n+2}{2}+\cdots +\binom{n+k}{k}$ I was trying to install minted package in TeXLive. I installed it and then run sudo tlmgr update --all. It was running slow so I stopped it using Ctrl+Z in an ubuntu terminal and then I run sudo tlmgr update --list. After that I installed texlive-latex-extra and python-pygments. Later on I run sudo tlmgr update --all again and let it finish.  After that I am trying to run a simple code using listings and greek but I get an error     Bad Character code (256)   A MWE that illustrated the problem is the following  \documentclass{book}  \usepackage[english,greek]{babel} \usepackage[iso-8859-7]{inputenc} % %\usepackage[utf8]{inputenc} \usepackage{kerkis} \usepackage{pifont} % %  \newcommand{\sw}{\selectlanguage{english}} \newcommand{\sq}{\selectlanguage{greek}} \newcommand{\eng}[1]{\latintext#1\greektext} \newcommand{\gre}[1]{\greektext#1\latintext}  \usepackage{xcolor} \usepackage{listings} \usepackage{textcomp}  \definecolor{listinggray}{gray}{0.9} \definecolor{lbcolor}{rgb}{0.9,0.9,0.9}  \lstdefinestyle{JavaStyle}{         backgroundcolor=\color{lbcolor},     tabsize=4, %   rulecolor=,     language=Java,      % choose the language of the code         basicstyle=\scriptsize,     % the size of the fonts that are used for the code         upquote=true,         aboveskip={1.5\baselineskip},         columns=fixed,         showstringspaces=false,         extendedchars=false,         breaklines=true,         prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},         frame=single,         numbers=left,         showtabs=false,         showspaces=false,         showstringspaces=false,         identifierstyle=\ttfamily,         keywordstyle=\color[rgb]{0,0,1},         %commentstyle=\color[rgb]{0.026,0.112,0.095},         commentstyle=\itshape\color{green!40!black},         stringstyle=\itshape\color{red!90!black},         numberstyle=\itshape\color{yellow!50!black} }  \lstdefinestyle{CppStyle}{         backgroundcolor=\color{lbcolor},     tabsize=4, %   rulecolor=,     language=C++,       % choose the language of the code         basicstyle=\scriptsize,     % the size of the fonts that are used for the code         upquote=true,         aboveskip={1.5\baselineskip},         columns=fixed,         showstringspaces=false,         extendedchars=false,         breaklines=true,         prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},         frame=single,         numbers=left,         showtabs=false,         showspaces=false,         showstringspaces=false,         identifierstyle=\ttfamily,         keywordstyle=\color[rgb]{0,0,1},         %commentstyle=\color[rgb]{0.026,0.112,0.095},         commentstyle=\itshape\color{green!40!black},         stringstyle=\itshape\color{red!90!black},         numberstyle=\itshape\color{yellow!50!black} } \begin{document}  This is a dummy text. kjhbki \end{document}   The .aux file says  \relax  \select@language{greek} \@writefile{toc}{\select@language{greek}} \@writefile{lof}{\select@language{greek}} \@writefile{lot}{\select@language{greek}}   while the .log file can be found   Any idea why is this happening and how to fix this? Note that if I remove the listings preamble, delete all produced files and build the document, everything works fine.