For some reason whenever I test this, the IDE throws a NullPointerException at line 46 (the for loop that check the array for a name). It seems to work, since it fetches the name and returns it, but then immediately follows with the exception. Can anyone explain? Thanks!  import java.util.*; class PhoneNumbers {  private String name; private String number;  PhoneNumbers(String n, String numb) {     this.name = n;     this.number = numb; }  public String getName() {     return name; }  public String getNumber() {     return number; }  public static void main(String[] args) {     Scanner sc = new Scanner(System.in);     boolean repeat = true;     int count = 11;     PhoneNumbers[] contacts = new PhoneNumbers[30];      contacts[0] = new PhoneNumbers("Gina", "(847) 342-0912");     contacts[1] = new PhoneNumbers("Marcia", "(847) 341-2392");     contacts[2] = new PhoneNumbers("Rita", "(847) 354-0654");     contacts[3] = new PhoneNumbers("Jennifer", "(414) 234-0912");     contacts[4] = new PhoneNumbers("Fred", "(414) 435-0434");     contacts[5] = new PhoneNumbers("Neil", "(608) 123-0914");     contacts[6] = new PhoneNumbers("Judy", "(608) 123-0312");     contacts[7] = new PhoneNumbers("Arlene", "(608) 123-0312");     contacts[9] = new PhoneNumbers("LaWanda", "(920) 787-9813");     contacts[10] = new PhoneNumbers("Deepak", "(930) 412-0991");      while (repeat) {         boolean found = false;          System.out.print("Enter your friends name: ");         String nameInput = sc.nextLine();           if (!nameInput.equalsIgnoreCase("quit")){               for(int i = 0; i &lt; count - 1; i++){                     if (contacts[i].getName().equalsIgnoreCase(nameInput)) {&lt;---Here's where the issue occurs***                         found = true;                         System.out.println(contacts[i].getName() + "'s number is " + contacts[i].getNumber());                 }              }              if (!found){                  System.out.println("Enter your friends phone number: ");                  String num = sc.nextLine();                   contacts[count + 1] = new PhoneNumbers(nameInput, num);                  count++;              }          }else if (nameInput.equalsIgnoreCase("quit")) {             repeat = false;         }else if (count == 30){              repeat = false;              }         }     } }
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?
Prove that the function $f(x)=\frac{x}{x^2+1}$ is continuous at $x=-1$. Prove  that the function $\displaystyle f(x)=\frac{x}{x^2+1}$ is continuous at $x=-1$. You should give a proof that is directly based on the  definition of continuity.   I saw many similar questions on this website, but none of them gave me a satisfactory answer. I more or less understand how epsilon-delta proofs work but my problem lies more in the algebraic manipulations probably. So here's my "attempt".  Definition of continuity; for $f:A \to \mathbb{R}$     $$\forall \varepsilon &gt;0 \ \exists\delta&gt;0\ \forall x \forall x_0 \in A:|x-x_0|&lt;\delta \Rightarrow |f(x)-f(x_0)|&lt;\varepsilon$$   So from what I understand, the procedure for epsilon-delta proofs are as follows: 1. Plug the point of interest $x_0$ into $|f(x)-f(x_0)|&lt;\varepsilon$ 2. Write $x$ in terms of $\varepsilon$ 3. Then plug $x$ into $|x-x_0|&lt;\delta$ 4. Find $\delta$ in terms of $\varepsilon$. Done    At step 1, we have $\left|\dfrac{x}{x^2+1}+\dfrac{1}{2}\right|&lt;\varepsilon$. Step 2 is where I'm stuck because of the 2nd degree polynomial in the denominator. First, I did this: $\left|\dfrac{x}{x^2+1}\right|&lt;\left|\dfrac{x}{x^2+1}+\dfrac{1}{2}\right|&lt;\varepsilon$. Then, I wasn't too sure about what to do, I thought about getting rid of the "$1$", but that would screw up my inequality. I thought about factoring $x^2+1$, but it doesn't have any real roots. I tried inverting the fraction, but that led me to nowhere. And I've already exhausted the tools I have. How do I proceed?  Apparently, epsilon-delta proofs are the most basic building blocks of analysis. And I'm already failing, this is both embarrassing and depressing... Why does instanceof return false for some literals? &quot;foo&quot; instanceof String //=&gt; false &quot;foo&quot; instanceof Object //=&gt; false  true instanceof Boolean //=&gt; false true instanceof Object //=&gt; false false instanceof Boolean //=&gt; false false instanceof Object //=&gt; false  12.21 instanceof Number //=&gt; false /foo/ instanceof RegExp //=&gt; true  // the tests against Object really don't make sense  Array literals and Object literals match... [0,1] instanceof Array //=&gt; true {0:1} instanceof Object //=&gt; true  Why don't all of them? Or, why don't they all not? And, what are they an instance of, then? It's the same in FF3, IE7, Opera, and Chrome. So, at least it's consistent. I am a non-EU national, permanent UK Resident. Recently, my work issued me with a multiple Schengen visa with Norway as the first (main) point of entry. Now I want to go on holidays to Greece - do I need to apply to Schengen visa again, as Greece is not Norway and I am not going there for work? How to reset the terminal properties and preferences? Why no tag Badges for Good questions Why not make  but for questions too?  I love that everything is well though behind SO but I can't see no reason as to why great questions can't be prized with "Badges by subject". How can I "grep" patterns across multiple lines? It seems I am misusing grep/egrep.   I was trying to search for strings in multiple line and could not find a match while I know that what I'm looking for should match. Originally I thought that my regexes were wrong but I eventually read that these tools operate per line (also my regexes were so trivial it could not be the issue).  So which tool would one use to search patterns across multiple lines? If $a,b,c$ are positive integers,and $\cfrac{a}{b}+\cfrac{b}{c}+\cfrac{c}{a}$ and $\cfrac{b}{a}+\cfrac{c}{b}+\cfrac{a}{c}$ are integers then $a=b=c$ Let $G$ a group with normal subgroups $M,N$ such that $M\cap N=\{e\}$. Show that if $G$ is generated by $M\cup N$ then $G\cong M \times N$. Without using any non-standard (Windows included) utilities, is it possible to download using the Windows command line?  The preferred version is Windows XP, but it's also interesting to know for newer versions.  To further clarify my question:   It has to be using HTTP The file needs to be saved Standard clean Windows install, no extra tools   So basically, since everybody is screaming , I want simple Wget functionality, without using Wget. Suppose $f(x)$ is linear i.e. $f(x + y) = f(x) +f(y) $ and monotone on $[-\infty, +\infty]$, then $f(x) = ax$, a real. Suppose $f(x)$ is linear i.e. $f(x + y) = f(x) +f(y) $ and monotone on $[-\infty, +\infty]$, then $f(x) = ax$, a real.  We know $f(0)=0$, and if one assumes differentiability it is quite easy.      But how does monotone make up for differentiability? Expanding the equation out gives  $(3^{2n}\times3)+(2^n\times2^2) \equiv 0\pmod{7}$   Is this correct? I'm a little hazy on my index laws.  Not sure if this is what I need to do? Am I on the right track? How to cheat and avoid cheating in Flash games? How to select a Master's thesis topic if your advisor won't suggest one? If a master's degree candidate needs to select a thesis topic, but their advisor is unwilling to offer suggestions on the matter, how should one go about selecting a thesis?   How might one select an area to study? How can one evaluate if if is a suitable topic? Does the thesis need to focus on an area which is relatively unexplored by prior research? amsalpha-like bibtex style with manual labels Beginner here with an issue on a simple presentation using beamer  \documentclass{beamer}  \begin{document} \begin{frame}   \tau \epsilon \chi \end{frame} \end{document}   The above fails with the message "! Missing $ inserted." and waits for me to do something when converting to pdf. I have tried adding the instruction \usepackage[utf8]{inputenc} and also \usepackage[greek]{babel}. I have not seen references either to needing to use any other package. What is exactly I am missing? I tried to prove this question but without a success: Let $K_1$ and $K_2$ be definable sets, prove that $K_1\cup K_2$ is definable.  What I tried to do is to assume: $K_1=Ass(X)=\{ v|v \vDash X \}$ and $K_2=Ass(Y)=\{ v|v \vDash Y \}$ and to say that $K_1\cup K_2=Ass(X \cap Y)$. but I couldn't prove that: $K_1\cup K_2 \supseteq Ass(X \cap Y)$ .   I would like to get help with this proof SyntaxError: Non-ASCII character '\xa3' in file when function returns '£' Why should I declare a virtual destructor for an abstract class in C++? I know it is a good practice to declare virtual destructors for base classes in C++, but is it always important to declare virtual destructors even for abstract classes that function as interfaces? Please provide some reasons and examples why. Diffinitive rules for using Android's getBaseContext, getApplicationContext or using an Activity's "this" I have a very large folder that I am trying to create a tar archive of. The issue is I don't have enough extra free space to store the entire archive so I want to create say 100-200GB chunks of the archive at a time and transfer those individually to cloud storage. I need to be able to control when new chunks are created so my HDD doesn't fill up but all of the commands i've found to create split tarballs always create it all at once, in the same directory. The closest solution I found was from  but all the responses base the archives on number of files, not size which is important for my use case as my file sizes are unevenly distributed.