I am writing a piece of software that requires the use of a class in another file. When I run the program and put in a value, I get the error Exception in thread "main" java.lang.NullPointerException class. Here is my code:      package chap8lab.salesperson;  import javax.swing.JOptionPane;  public class Chap8LabSalesPerson {  public static void main(String[] args) {     final int LIMIT = 10;     Salesperson[] peep = new Salesperson[LIMIT];     int i = 0, a = 0;     String q = "q", strInput = "";       JOptionPane.showMessageDialog(null,         "This program collects salesperson data.");         while (!strInput.equals(q))         {         strInput = JOptionPane.showInputDialog(null,                 "Enter sales person ID (\"q\" to quit)");         if (!strInput.equals(q) &amp;&amp; !strInput.matches("[a-z][A-Z]"))         peep[i].setEmpID(Integer.parseInt(strInput));         if (!strInput.equals(q))         strInput = JOptionPane.showInputDialog(null,                 "Enter sales amount (\"q\" to quit)");         if (!strInput.equals(q) &amp;&amp; !strInput.matches("[a-z][A-Z]"))           peep[i].setSalesAmt(Double.parseDouble(strInput));         i++;         if (strInput.equals(q))             i--;         }         while (a &lt; i)         {             JOptionPane.showMessageDialog(null,                      "Employee ID: " + peep[a].getEmpID()                     + " Sales Ammount: " + peep[a].getSalesAmt() + "\n");          a++;         }         JOptionPane.showMessageDialog(null,                      "Thank you for using this program.\nHave a nice day!");     }  }   Here is my class file Salesperson.java:       package chap8lab.salesperson;  public class Salesperson { private int empID; private double salesAmt;  public Salesperson() {     empID = 9999;     salesAmt = 0; }  public void setEmpID(int newEmpID) {     empID = newEmpID; }     public int getEmpID() {     return empID; }        public void setSalesAmt(double newSalesAmt) {     salesAmt = newSalesAmt; }   public double getSalesAmt() {     return salesAmt; }  }   Any help is greatly appreciated.
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?
What is the point of the Red Thread/Tape around evidence or newspaper clippings? I have seen in a lot-lot of movies that the person who searches for a crime or another person creates a web of red tape or wire around the newspapers and evidence he acquires. I never guessed its usefulness and am therefore asking why do they do it?  Here is an illustration I created: Let $T=\{z:|z|=1 \mathbin{\text{and}} z \in \mathbb C\}$ be the unit circle in the complex plane, considered as a topological group under complex multiplication and the usual topology. Show that every subgroup of $T$ is either dense in $T$ or finite.  How to prove the denseness? How to set file input value when dropping file on page? How Do I Allow A Standard User to Install Programs? Yes, I realize that defeats the purpose of standard user. But here is the situation. A friend of mine wants to set up time limits for his home schooled son, and his son needs to be a standard user in order to use Family Safety. But at the same time, his son (who I personally think is way too old to have time limits), needs to be able to update and install some of his games on his computer. So I guess it's just sort of "light" parental control (just something to help him focus and not get distracted with hours of gaming).  It is the basic version of Windows 8.1, so there is no Group Policy editor (gpedit.msc). However, I'm fairly good with computers and I figured out how to install it. But it doesn't have a lot of the features that the "real" gpedit seems to have. Here is an example of what is in my gpedit: List selectors for Objective-C object I have an object, and I want to list all the selectors to which it responds. It feels like this should be perfectly possible, but I'm having trouble finding the APIs. I always thought Java uses pass-by-reference. However, I've seen a couple of blog posts (for example, ) that claim that it isn't (the blog post says that Java uses pass-by-value). I don't think I understand the distinction they're making. What is the explanation? IBus methods do not show up in text entry settings I installed both Korean and Japanese using the Language Support window, and expected Korean (Hangul) and Japanese (Anthy) to show up in the input sources for Text Entry Settings (having both packages installed). However, neither shows up. What is the difference between can and could in 'Can/could you please explain this to me?' find a sequence converging to zero but not the element of lp space for every 1<_p<infinity Is "from where" grammatically equivalent to "from which"? For whatever reason, we do no longer need to be root (or using sudo) to run /sbin/shutdown, /sbin/reboot etc.  This seems to be because those executables are now symlinks to /bin/systemctl which handles everything as normal user.  However, what if I want shutdown and reboot to require root authentication again? How can I achieve this? Looking out into the universe means looking back in time - how does that work? This is a question that has been gnawing on me for many years now. Back a long time ago, as I recall in reference to a scene in a popular science show on TV, I was asked the following.  The claim is that when you look out into the universe, you see the universe as it appeared at some past time. (This follows from the speed of light being finite, and looking at objects by observing their emitted light or other EM radiation.) The amount of time that one looks backwards is equal to the distance to the observed object in light-distance (so looking at something ten lightyears away means you are observing it as it was ten years ago).  Matter moves at a rate of speed less than the speed of light (it has to, since matter has mass, even if miniscule at the atomic level). So $v_{mass} \lt v_{EM}$ (probably significantly less, since $v_{EM} = c$).  So let's say you're looking at an object $10^{10}$ lightyears away by observing something for which $v=c$. To the observer, that object appears as it was $10^{10}$ years ago. But the Earth is much younger than $10^{10}$ years and we established that matter moves at a slower speed than EM radiation, so wouldn't the radiation that was emitted $10^{10}$ years ago long since have passed Earth's current position?  If, say, $v_{mass} = 0.5 \times c$ (a big assumption, but bear with me for a second), it would seem that the radiation emitted $10^{10}$ years ago would have passed Earth's current position $10^{10} - (0.5 \times 10^{10}) = 5 \times 10^{9}$ years ago, around the time when the solar system was still forming. Setting $v_{mass} = 0.25 \times c$ (which seems more realistic) means the radiation would have passed "us" around $7.5 \times 10^{9}$ years ago. So how could we be observing it now?  I'm not sure I'm posing this question in the best possible way (I'll admit I do find the concept somewhat confusing), and I'm sure that there's a simple explanation for it all. Just what am I missing?  I did find  which seems peripherally related but not quite the same thing. Qmechanic brought up  but that question seems to be about whether it is so, not why it is so. Migrated question's answers can be upvoted twice by the same user How to download Ubuntu Server backups automatically? I'm thinking of an investment in a new root server running ubuntu. Due to the fact, that the provider won't have extra backup-space, I need an other solution.  Is it possible to download the server backups automatically when my desktop machine is connected to the internet and in idle state? We were trying to come up with an easy way to generate a rational number in between two existing rational numbers with a fairly low numerator and denominator (the way we were doing this earlier was to find the average of the two rationals, but that results in a denominator of up to $c * d$. Does this inequality hold for all values of $a, b, c, d$? Can't use String#trim as a callback for Array#map I was wondering if $\mathbf{A}\times\mathbf{C}=\mathbf{B}$ and $\mathbf{A}\cdot{\mathbf{C}}= p$, is it possible to express C in terms of A, B, and p?  Note: A, B, C are vectors and p is a scalar.  Sorry if this question has been asked before. If so, can anyone give me a link to it? How to make specifics apps password protected even after passcode in iPhone? What is the standard solution in JavaScript for handling big numbers (BigNum)? How do I wrap a macro definition in an environment?