Cannot find NullPointerException in lottery application I am making a program that makes a randomized lotto ticket and compares it to a user's set of numbers. My problem is I cannot locate the error of NullPointerException. I also feel like my method for comparing numbers is sub-optimal but I can't think of better way to write it.  package lotteryapplication;  import java.util.Random; import java.util.Scanner;  public class LotteryApplication {      public static int lotteryNumbers[];     public static int usersNumbers[] = new int[5];      /**      * @param args the command line arguments      */     public static void main(String[] args) {          System.out.println(                 " This is the lottery. Numbers in my lottery range from 1 through 60.");         System.out.println(" See if you can win\n");         getUserPicks();         getRandomNumbers();         checkLotteryMatch();     }      public static void getUserPicks() {         Scanner keyboard = new Scanner(System.in);         for (int i = 0; i &lt; 5; i++) {             System.out.print(String.format(                     "Enter a Number from 1 through 60 for spot :" + (i + 1))                     + "\n");             usersNumbers[i] = keyboard.nextInt();             keyboard.nextLine();         }     }      public static void getRandomNumbers() {         int lotteryNumbers[] = new int[5];         Random r = new Random();         for (int i = 0; i &lt; 5; i++) {             lotteryNumbers[i] = r.nextInt(60) + 1;         }     }      public static void checkLotteryMatch() {         int matchedNums = 0;         if (usersNumbers.length == lotteryNumbers.length) {              for (int i = 0; i &lt; lotteryNumbers.length; i++) {                 if (usersNumbers[0] == lotteryNumbers[i]) {                     matchedNums++;                 }             }             for (int i = 0; i &lt; lotteryNumbers.length; i++) {                 if (usersNumbers[1] == lotteryNumbers[i]) {                     matchedNums++;                 }             }             for (int i = 0; i &lt; lotteryNumbers.length; i++) {                 if (usersNumbers[2] == lotteryNumbers[i]) {                     matchedNums++;                 }             }             for (int i = 0; i &lt; lotteryNumbers.length; i++) {                 if (usersNumbers[3] == lotteryNumbers[i]) {                     matchedNums++;                 }             }             for (int i = 0; i &lt; lotteryNumbers.length; i++) {                 if (usersNumbers[4] == lotteryNumbers[i]) {                     matchedNums++;                 }             }             for (int i = 0; i &lt; lotteryNumbers.length; i++) {                 if (usersNumbers[5] == lotteryNumbers[i]) {                     matchedNums++;                 }             }         }         if (matchedNums == 1) {             System.out.println("You only got one match sorry you win nothing.");         }         if (matchedNums == 2) {             System.out.println("You only got two matched sorry you win nothing");         }         if (matchedNums == 3) {             System.out.println(                     "you will recieve a free Lottery ticket as the prize");         }         if (matchedNums == 4) {             System.out.println("You will recieve a $2,000 prize");         }         if (matchedNums == 5) {             System.out.println("You will recieve a 500,000 prize");         }         if (matchedNums == 6) {             System.out.println("You will recieve a grand prize of $1,000,000");         }     } }
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?
I want to typeset a piece of code containing line breaks.  New lines should indent to a specified point in the previous line.  Here is a monospaced example to illustrate what I mean.  Notice how 'case' and 'of' line up below, as well as 'let' and 'in':  swap : forall a, b. Tuple a b -&gt; Tuple b a swap a b x = case x              of tuple a b y z. let x' = tuple b a z y                                in x'   The code I want to typeset is not monospaced, so I can't just use a verbatim environment to get what I want.  The actual LaTeX of the first line, for instance, is  \mathsf{swap} : \forall\alpha,\beta.\;\mathsf{Tuple}\;\alpha\;\beta\to\mathsf{Tuple}\;\beta\;\alpha   How can I align some text to a specific point in the previous line? Understanding shape and calculation of confidence bands in linear regression I am trying to understand the origin of the curved shaped of confidence bands associated with an OLS linear regression and how it relates to the confidence intervals of the regression parameters (slope and intercept), for example (using R):  require(visreg) fit &lt;- lm(Ozone ~ Solar.R,data=airquality) visreg(fit)     It appears that the band is related to the limits of the lines calculated with the 2.5% intercept, and the 97.5% slope, as well as with the 97.5% intercept, and the 2.5% slope (although not quite):  xnew &lt;- seq(0,400) int &lt;- confint(fit) lines(xnew, (int[1,2]+int[2,1]*xnew)) lines(xnew, (int[1,1]+int[2,2]*xnew))     What I don't understand are two things:   What about the combination of 2.5% slope &amp; 2.5% intercept as well as 97.5% slope and 97.5% intercept? These give lines that are clearly outside the band plotted above. Maybe I don't understand the meaning of a confidence interval, but if in 95%  of the cases my estimates are within the confidence interval, these seem like a possible outcome? What determines the minimum distance between the upper and lower limit (i.e. close to the point where the two lines added above intercept)?    I guess both questions arise because I don't know/understand how these bands are actually calculated.   How can I calculate the upper and lower limits using the confidence intervals of the regression parameters (without relying on predict() or a similar function, i.e. by hand)? I tried to decipher the predict.lm function in R, but the coding is beyond me. I'd appreciate any pointers towards relevant literature or explanations suitable for stats beginners.  Thanks. What does it mean that GUIkit is being deprecated? What is the reasoning behind the design decision to allow users to create a display name which matches another existing users exactly?    This is opposed to the common practice of enforcing unique user names, and I'd really like to learn something. Maps from subsets of $\mathbb{R}^2$ that are either open/closed/continuous I'm self studying J. Lee's Introduction to Topological Manifolds, and after doing all other exercises on chapter 2, I can't seem to come with the proper counterexamples for this one.      For each of the following properties, give an example consisting of two subsets $X, Y \subset \mathbb{R}^2 $, both considered as topological spaces with their Euclidean topologies, together with a map $f: X \rightarrow Y$ that has the indicated property.         Open but not closed/continuous   Closed but not open/continuous    Continuous but not open/closed         etc... (all cases)   I think the reason for my difficulty is a lack of geometric intuition of what open, closed and continuous maps look like as deformations of shapes in $\mathbb{R}^2$ (I can construct counterexamples from artificial made up spaces).   I tried squashing balls and 'pumping space' into lines, as well as joining strips in annulus shapes, but all the examples I seem to come up with are either too well behaved (i.e. all 3) or too misbehaved.   Instead of a case by case answered I would prefer a couple worked out cases and some intuition on how to visualise open / closed maps in this context. Read Gif Images using WebView android I want to ask about two sentences, and what would be the correct way to form a question:   It's very important that we eat healthy food, ...........?  Which would be the correct question tag: (isn't it) or (don't we)? It's a must that all applicants follow the rules of the competition, ..........?  Which would the correct question tag: (don't they) or (mustn't they)?   Please could you tell me the correct answers, and, more importantly, why those are correct? Create file and its parent directory I know that touch command creates a file:  touch test1.txt   but how I can create a file and its full path?  for example my desktop contains nothing:  ~/Desktop/$ ls ~/Desktop/$   and I want to create 1.txt in ~/Desktop/a/b/c/d/e/f/g/h/1.txt. Can I do this with a simple command like:  $ touch ~/Desktop/a/b/c/d/e/f/g/h/1.txt   instead of create full path manually and then create the file? I need to write a small program that can detect that it has been changed. Please give me a suggestion!  Thank you. Why does Javascript getYear() return 108? Why does this javascript return 108 instead of 2008? it gets the day and month correct but not the year?  myDate = new Date(); year = myDate.getYear();   year = 108? How do I add VBA in MS Office? I've seen posts showing answers which use VBA () code/macros, however, I've also noted additional comments afterwards about how to use the VBA (how to implement and execute it). I'm hoping this will help just to get the code executed.   So, my question is:  I have some VBA code. How do I add VBA to my MS Excel or Word or Outlook project? Showing a set is nowhere dense in $C([0,1])$ I am technically knowledgeable enough to know that this most likely isn't possible, BUT, I am curious just the same (it must be put to rest). Is there anything preventing us from creating a means to use two different internet connections, like two different ethernet cards or an ethernet card and a wireless card, and using the two IP addresses at once for more internet speed?  My specific situation is that I would like to use both a wireless card and my wired connection on my machine running Kubuntu 13.10. Using two internet connections would allow me to do things like:   Torrent and browse simultaneously without lag Open Firefox with multiple tabs faster (?) Download a couple or a few large files at once double time Increase overall internet connection speed (?) $|a_{n+1}-a_n| \leq \frac{1}{2} |a_{n}-a_{n-1}|$. I'm trying to show that $(a_n)$ is convergent by showing that $(a_n)$ is Cauchy.  let $|a_2 - a_1 |  =x$.   $|a_3-a_2| \leq \frac{1}{2}x$  $|a_4-a_3| \leq \frac{1}{2}|a_3-a_2|\leq \frac{1}{4}x$  In general, for every $n$:  $|a_{n+1}-a_n| \le \frac {1}{2^{n-1}}x$  Let $\epsilon &gt;0$  for every $m,n &gt; 0 $, say $m&gt;n$ the following holds:  $$|a_m-a_n| = |a_m-a_{m-1} + a_{m-1} - a_{m-2} \dots a_{n+1}- a_n| \le$$  $$|a_m-a_{m-1}| + |a_{m-1} - a_{m-2}| + \dots |a_{n+1}-a_n| \leq \frac{x}{2^{m-2}} + \frac{x}{2^{m-3}} + \dots + \frac{x }{2^{n-1}}$$.  I can say that for big enough $n,m$, $|a_m-a_n|&lt;\epsilon$ and therefore, this sequence is Cauchy? It sounds not good enough to me yet I don't know what else to do here. Use filecontents environment to write a binary file In  of mine, I was trying to show how to embed an audio file into the pdf with the multimedia package. The resulting MWE does not stand on its own because it requires an example audio file.  I guess my first question is, does TeXLive include any example audio files? The second, and potentially less uninteresting question is, can I use the filecontents environment, or some other environment, to create a binary file?  \documentclass{article} \usepackage{graphicx} \usepackage[implicit=false]{hyperref} \usepackage{multimedia}  % What goes in here to produce a usable wav file. Happy to use a different environment. \begin{filecontents}{\jobname.wav} \end{filecontents}  \begin{document} \sound[inlinesound]{\includegraphics{example-image}}{\jobname.wav} \end{document} How do I completly remove XP from my pc. I currently have a dual boot with XP and Windows 7. Since installing Windows 7, I have never used XP. Can I remove it without causing problems with Windows 7? I setup my Nginx conf as per  , and now http2 is available...  But in Chrome (Version 54.0.2840.98 (64-bit))  Dev tool, it's always on HTTP 1/1 :  NAME             METHOD  STATUS  PROTOCOL shell.js?v=xx..    GET    200     http/1.1   my server is running Ubuntu 16.04 LTS which supports both ALPN &amp; NPN , and the openssl version shipped with it is 1.0.2g  I checked http2 support with and the result is :    Yeah! example.com supports HTTP/2.0. ALPN supported...   Also checking with curl is OK   $ curl -I --http2 https://www.example.com   HTTP/2 200    server: nginx/1.10.0 (Ubuntu)   date: Tue, 13 Dec 2016 15:59:13 GMT   content-type: text/html; charset=utf-8   content-length: 5603   x-powered-by: Express   cache-control: public, max-age=0   etag: W/"15e3-EUyjnNnyevoQO+tRlVVZxg"   vary: Accept-Encoding   strict-transport-security: max-age=63072000; includeSubdomains   x-frame-options: DENY   x-content-type-options: nosniff   I also checked with is-http2 cli from my console  is-http2 www.amazon.com × HTTP/2 not supported by www.amazon.com Supported protocols: http/1.1  is-http2 www.example.com ✓ HTTP/2  supported by www.example.com Supported protocols: h2 http/1.1   tested with openssl from my localhost  $ echo | openssl s_client -alpn h2 -connect www.example.com:443 | grep ALPN  depth=2 O = Digital Signature Trust Co., CN = DST Root CA X3  verify return:1  depth=1 C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3  verify return:1  depth=0 CN = example.com  verify return:1  ALPN protocol: h2  DONE   why Chrome is left behind it ? How can I check it also with Safari (v 10.0.1) I'm very confused about tenses.  I have examples in two different situations here. Situation 1: I went to New York two months ago and was talking to someone about it.  A. This is the first time I've been to New York. B. That was the first time I'd been to New York.  Which is correct in a daily conversation?  Situation 2: I'm going to New York next month and talking to someone.  A. This will be the first time I've been to New York. B. This is the first time I've been to New York. C. This will be the first time I go to New York.  Which sentence is appropriate?  According to a grammar article I've read before, I think it says that I can use this sentence in both cases:  This is the first time I've been to New York.  But I'm not sure if this is really so. So I'd like to know which tense I should use in each case. Could you explain it? For example, here are top five accounts in each site (this picture was taken when I was in Biology SE).    As you can see, all the badges are DNA, while Academia's badges should be hats, so on.  What do you think? Session lost when switching from HTTP to HTTPS in PHP When sending the user to a checkout page, they are switched from http://sitename.com to https://sitename.com.  As a result, $_SESSION variables are lost.  The site has a valid SSL certificate which may or may not be of some use.