To practice my basic programming skills over the summer I decided to write a 1dimensional motion physics problem solver. I am getting a java.lang.Nullpointerexception error whenever I try to run the program. I can't figure out what I've written incorrectly to give me the error. NOTE: Right now I am assuming the input for the solveFor variable will be "acceleration" for the sake of fixing this error:   import java.util.Scanner;  public class PhysicsProblem { private double vI; // initial velocity   private double vF; // final velocity     private double t;  // time  private double deltaX;  // change in the x value private double accel; private String missingVar;  public PhysicsProblem (double acceleration, double initialV, double finalV, double time, double changePosition)  {     acceleration = accel;     initialV = vI;     finalV = vF;     time = t;     changePosition = deltaX;     }  Scanner scan = new Scanner(System.in);  public void getUnknownsAccel() {     //-----------     // checks for another unknown value that is not accel     //-----------     if (missingVar.equalsIgnoreCase("time"))     {         System.out.println("Please enter the value for time: ");         t = scan.nextDouble();         while (t &lt;= 0 || !scan.hasNextDouble())         {             System.out.println("That is not an acceptable value!");             t = scan.nextDouble();         }     }            if (missingVar.equalsIgnoreCase("initial velocity"))     {         System.out.println("Please enter the value for initial velocity: ");         vI = scan.nextDouble();         while (!scan.hasNextDouble())         {             System.out.println("That is not an acceptable value!");             vI = scan.nextDouble();         }     }     if (missingVar.equalsIgnoreCase("final velocity"))     {         System.out.println("Please enter the value for final velocity: ");         vF = scan.nextDouble();         while (!scan.hasNextDouble())         {             System.out.println("That is not an acceptable value!");             vF = scan.nextDouble();         }     }     if (missingVar.equalsIgnoreCase("delta X"))     {         System.out.println("Please enter the value for delta X: ");         deltaX = scan.nextDouble();         while (!scan.hasNextDouble())         {             System.out.println("That is not an acceptable value!");             deltaX = scan.nextDouble();         }     } }   This is the class file for the program. I'm getting an error in the line 36:  "if (missingVar.equalsIgnoreCase("time"))"  As well as getting an error in line 40 of the main program body:  "problem1.getUnknownsAccel();"  public static void main (String[] args) {      String missingVar;      // other missing variable     double vI = 0;     double vF = 0;     double t = 0;     double deltaX = 0;     double accel = 0;     Scanner scan = new Scanner(System.in);      PhysicsProblem problem1 = new PhysicsProblem (accel, vI, vF, t, deltaX);      System.out.println("Which variable are you solving for? ");     String solveFor = scan.nextLine();       // after receiving solveFor input, assesses data accordingly      if (solveFor.equalsIgnoreCase("acceleration"))     {         System.out.println("Solving for Acceleration!");         System.out.println("Are there any other unknowns? (enter 'none' or the name " +                 "of the variable)");         missingVar = scan.nextLine();         do         {             problem1.getUnknownsAccel();             System.out.println("Are there any other unknowns? (enter 'none' or the name " +                     "of the variable)");             missingVar = scan.nextLine();         }            while (!missingVar.equalsIgnoreCase("none") || !missingVar.equalsIgnoreCase("acceleration"));          if (missingVar == "none");         {             // Write code for finding solutions             System.out.println("Assuming you have given correct values, the solution is: ");         }     }   Why is it throwing an exception?
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?
Use of .apply() with 'new' operator. Is this possible? Simple Past vs. Present Perfect: "was" vs. "has been" Prove the function is continuous, exercise from Conway's "Functions of One Complex Variable I" factorization of a^n+1? I'm trying to prove that $a^n+1$ can only be prime if $n$ is a power of $2$. Is there a general factorization of $a^n+1$? states that if $a, b \geq 0$, $p, q &gt; 0$, and $\frac{1}{p} + \frac{1}{q} = 1$, then $$ab\leq \frac{a^p}{p} + \frac{b^q}{q}$$ (with equality only when $a^p = b^q$).  Back when I was in my first course in real analysis, I was assigned this as homework, but I couldn't figure it out.  I kept trying to manipulate the expressions algebraically, and I couldn't get anywhere.  But every proof that I've seen since uses calculus in some way to prove this.  For example, a common proof is based on this  and integration.  The proof on Wikipedia uses the fact that $\log$ is concave, which I believe requires the analytic definition of the logarithm to prove (correct me if I'm wrong).  Can this be proven using just algebraic manipulations?  I know that that is a somewhat vague question, because "algebraic" is not well-defined, but I'm not sure how to make it more rigorous. But for example, the proof when $p = q = 2$ is something I would consider to be "purely algebraic":  $$0 \leq (a - b)^2 = a^2 + b^2 - 2ab,$$ so $$ab \leq \frac{a^2}{2} + \frac{b^2}{2}.$$ I have a problem. I am going to make a minecraft animation in blender. But when I put a minecraft texture on a 3d cube that is 16x16x16 it is very low resolution is there a way to get the texture in a better resolution or is there a way to make blender make the texture better?  I hope you have an answer. Thanks in advance Categorize my data into 3 groups present continous or present perfect continous? Should I write 'I have been reading a book now' or 'I am reading a book now'? I started to read one week ago and I haven't ended yet. Thanks for help I noticed that some Indian languages (eg : Kannada) are not supported in Ubuntu 16.04.  See this screenshot:    Even with file names :    This was not happening in earlier Ubuntu editions. How can I enable kannada in Ubuntu 16.04? Equivalent definition of metric compatibility for a connection: what does $\nabla g$ mean? So the definition I know for metric compatibility is:  $$Xg(Y,Z)=g(\nabla_XY,Z)+g(Y,\nabla_XZ),$$   which make sense, as $g(Y,Z)$ is a smooth function from the manifold to reals and we think of $X$ as a derivation. So now I read this apparent equivalent definition that says $\nabla g=0$. Can someone explain what this means? How can I do $\nabla$ of $g$ I thought $g_p$ is an element of $T_p^*M\otimes T_p^*M$ at every point. Furthermore after you explain the meaning of this can you show me that these two definitions are indeed equivalent? Finding the sum of the series $\frac{1}{1!}+\frac{1+2}{2!}+\frac{1+2+3}{3!}+ \ldots$ Deteremine the sum of the series $$\frac{1}{1!}+\frac{1+2}{2!}+\frac{1+2+3}{3!}+ \ldots$$  So I first write down the $n^{th}$ term $a_n=\frac{\frac{n(n+1)}{2}}{n!}=\frac{n+1}{2(n-1)!}$.  So from there I can write the series as $$1+\frac{3}{2}+\frac{4}{2\times 2!}+\ldots +\frac{n+1}{2(n-1)!}+\ldots $$  I am quite sure I can do some sort of term by term integration or differentiation of some standard power series and crack this. Any leads? A short story about finding an inhabitable planet and meeting aliens So the story goes, humans in a spaceship search for an inhabitable planet, being surprised they found none in the vicinity of Earth. They find one, and it seems uninhabited. At the same time are observed by the aliens, who go down on the planet to meet them. The aliens sit them down and tell them a story about war and conflict that ruled the galaxy, and how all the sentient races in the galaxy got together and got rid of the race that tried to conquer all by blowing up their planets.  In the end you realise man is this terrible conqueror the aliens are talking about. Why is $\sqrt {12} = 2 \sqrt 3$? Flex: Figure out when the running swf was compiled? translation invariant of integral on $\mathbb{R}$ Problem 1: Let $f\in L^1(\mathbb{R})$, show $\int_\mathbb{R}f(t)dt=\int_{\mathbb{R}}f(x+t)dt,\forall x\in (-\infty, \infty)$.  Problem 2: Let $f\in L^1(\mathbb{R})$,show $\displaystyle \lim_{t\rightarrow 0}\int_{\mathbb{R}}|f(x+t)-f(x)|dx=0$.  My try for Problem 1:  Consider $\displaystyle \int_{\mathbb{R}}f(t)dt=\lim_{n\rightarrow \infty}\int_{-n}^nf(t)dt=\lim_{n\rightarrow \infty}\int_{\mathbb{R}}f_n(t)dt$, where $f_n(t)=f(t)\chi_{[-n,n]}$.  And since $dt=d(x+t)$, we have $\displaystyle \int_{-n}^nf(x+t)dt=\int_{-n+x}^{n+x}f(t)dt$.  So for each $x\in (-\infty,\infty)$,  $$ \begin{split} \int_{\mathbb{R}}f(t)-f(t+x)dt &amp;=\lim_{n\rightarrow \infty}\int_{\mathbb{R}}f(t)(\chi_{[-n,n]}-\chi_{[-n+x,n+x]})dt\\ &amp;=\lim_{n\rightarrow \infty}\int_{\mathbb{R}}f(t)(\chi_{[-n,-n+x]}-\chi_{[n,n+x]})dt\\ &amp;=\lim_{n\rightarrow \infty}\lim_{k\rightarrow \infty}\int_\mathbb{R}\varphi_k(t)(\chi_{[-n,-n+x]}-\chi_{[n,n+x]})dt\\ &amp;=\lim_{k\rightarrow \infty}\lim_{n\rightarrow \infty}\int_\mathbb{R}\varphi_k(t)(\chi_{[-n,-n+x]}-\chi_{[n,n+x]})dt \end{split} $$ where $\varphi_k(t)$ is simple function pointwise converges to $f(t)$, simple function vanish out of set of finite measure, so $\varphi_k(t)(\chi_{[-n,-n+x]}-\chi_{[n,n+x]})$ vanishes when $n$ big enough(is this right?)    Another try:  Since $f\in L^1$, $f$ is bounder a.e. so can be approximated by simple functions, and $\chi_{A+t}(x)=\chi_A(x-t)$,thus $$\int f(t)=\lim_n\int\varphi_n=\lim_n \sum_{i=1}^nc_i\mu(E_i)=\lim_n \sum_{i=1}^nc_i\mu(E_i-x)=\int f(t+x)$$  For problem 2, I guess they share the same method.   Any help or correction about these two problems? Thanks. Drawing a square root spiral I am using k-means clustering algorithm to cluster a given dataset into two. I took two different initial points and run k-means clustering algorithm for each initial points. With the first initial points I got “within cluster sum of squared distances” (error) =23874.341. With the second initial points I got “within cluster sum of squared distances” (error) = 42913.684. 23874.341 is less than 42913.684. So, can we say the first one is the better clustering quality? If yes, is it always hold true? Or can we say less within cluster sum of squared distances is always the better clustering quality? Find all functions $f(x)$ such that $f\left(x^2+f(y)\right)$=$y+(f(x))^2$ Cells not updating automatically I have a formula in a cell which counts the values in 2 other cells. Normally, after entering in the values in these 2 other cells, the formula cell updates automatically when Enter is pressed or when the cells are clicked out of.  However, for some reason, the value calculated by the formula does not update automatically. I am having to click on the formula bar, then I have to click enter for the formula cell to do its thing.  Why is this happening? Cardinality of a totally ordered union