Im using append on an empty array to create multiple projectiles, but every time I hit the spacebar Im getting a NullPointerException on keyPressed when it checks if the spacebar was pressed. I can't figure out why this is hapenning. Help would be really good.   MAIN CLASS:   int naveX, naveY; int inimigoX, inimigoY; Tiro [] tiros;  boolean tiroVisivel; boolean naveDireita, naveEsquerda;  void setup(){   size (800, 600);    naveX = 375; naveY = height - 120;   inimigoX = 385; inimigoY = 0;    tiroVisivel = false;   naveDireita = naveEsquerda = false;   }  void draw(){   background (0);    nave();   movimentoNave();   if (tiroVisivel == true &amp;&amp; tiros != null){     for (int i = 0; i &lt; tiros.length; i++){       tiros[i].display();       tiros[i].update();           }   }    inimigo(); }  void nave(){   stroke (255);   fill (255, 0, 0);   rect (naveX, naveY, 50, 100); }  void movimentoNave(){   if (naveEsquerda == true &amp;&amp; naveX &gt; 0){     naveX = naveX - 5;   }   if (naveDireita == true &amp;&amp; naveX &lt; width - 50){     naveX = naveX + 5;   } }  void inimigo(){   stroke (255);   fill (0, 100, 255);   rect (inimigoX, inimigoY, 30, 50); }  void keyPressed(){   if (key == ' '){     append(tiros, new Tiro(naveX + 20, naveY - 30));     tiroVisivel = true;   }    if(key == 'a' || key == 'A'){     naveEsquerda = true;     }   if(key == 'd' || key == 'D'){     naveDireita = true;   }    if (key == 'r' || key == 'R'){     setup();       } }  void keyReleased(){   if(key == 'a' || key == 'A'){     naveEsquerda = false;     }   if(key == 'd' || key == 'D'){     naveDireita = false;   }     }   PROJECTILE CLASS:  public class Tiro {    private int tiroX = naveX + 20;   private int tiroY = naveY - 30;    public Tiro(int x, int y){     this.tiroX = x;     this.tiroY = y;   }     void display(){     stroke (255);     fill (255, 0, 100);     rect (tiroX, tiroY, 10, 20);    }    void update(){     if (tiroY &gt; 0){       tiroY = tiroY - 10;     }   } }
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 have been trying to make a short clip of a bullet hitting a wine glass with wine in it, but I keep running into the same problem with the add-on. Every time I have used it the result has left me with at least a partial box being generated as several of the fractured pieces.  I have tried subdividing and/or adding a sub-surf modifier but the result only changes where the large distorted fragments end up. I have been having trouble with this for quite some time and I would greatly appreciate any help. Sort files alphabetically before processing I use the command  find . -type f -exec sha256sum {} \; &gt; sha256SumOutput   to hash every file in a folder hierarchy. Unfortunately, sha256sum doesn't get the file names from find in alphabetical oder. How can this be fixed?  I'd like to have them ordered before they are hashed so they are hashed in alphabetical order (this has a reason). First week of August in Scotland : What kind of clothes to pack? In a couple of weeks I will be going to Edinburgh, Scotland. I've been told that the weather is very unpredictable throughout the year. Can you suggest what I should pack as regards clothes? How do I get the square root of a complex number? If I'm given a complex number (say $9 + 4i$), how do I calculate its square root? why does loop-cut-and-slide ignore some faces but not others? I think it would be good to have a way for the user to view the target URL of a link before following it. I'm pretty sure that I'm not the only one who dislikes blind-clicking -tapping links.   When I use SE in the mobile browser, I routinely long-press links to find out where they go before following them. I wish I could do the same thing in the app, with the same or a similar method.  (It's important that this won't conflict with text selection, since you can't long-press on links to select them now anyway.) What does 100Ohm @ 100MHz exactly mean in ferrite beads? I am trying to understand the parameters of ferrite beads and having trouble in understanding the impedance vs frequency parameter.   What does 100Ohm at 100MHz exactly mean? Does it mean that the bead will provide impedance of 100Ohm for frequencies in the 100MHz region (depending on its graph)?  I do understand that bead is highly resistive at higher frequencies.  Any help will be appreciable. For example, if passed the following:  a = []   How do I check to see if a is empty? I have a data frame in python where I need to find all categorical variables. Checking the type of the column doesn't always work because int type can also be categorical.   So I seek help in finding the right hypothesis test method to identify if a column is categorical or not.   I was trying below chi-square test but I am not sure if this is good enough  import numpy as np data = np.random.randint(0,5,100) import scipy.stats as ss ss.chisquare(data)   Please advise. How can I copy the path to a folder or a file? The Info Dialog doesn't allow me to copy the information that stands there ...    Is there an easy way to do this? Hi currently Nagios sends notifications from nagios@server.domain.com, How do I go about configuring this? Thanks In $\mathbb{Z}/(n)$, does $(a) = (b)$ imply that $a$ and $b$ are associates? [Update: Based on the hints provided by @zcn and @whacka, I believe I have found a solution. See my answer below.]  Below, $R$ is a commutative ring with $1$.  In John J. Watkins' Topics in Commutative Ring Theory, the author observes that if $a$ and $b$ are associates in $R$, then they generate the same ideal: $(a) = (b)$. This is clearly true, because $a = ub$ and $b = va$ for some units $u$ and $v$, and so $a \in (b)$ and $b \in (a)$, whence $(a) \subset (b)$ and $(b) \subset (a)$. Indeed, we didn't even require $u$ and $v$ to be units to reach this conclusion.  The author then claims that if $R$ is not a domain, then the converse may not be true: we may have $(a) = (b)$ even if $a$ and $b$ are not associates. As a "counterexample" he gives $R = \mathbb{Z}/(6)$, with $a = 2 + (6)$ and $b = 4 + (6)$. Clearly these elements generate the same ideal: $(a) = (b) = \{0, 2 + (6), 4 + (6)\}$. The author asserts that $a$ and $b$ are not associates, but this is false: $5 + (6)$ is a unit, and $(2 + (6))(5 + (6)) = 4 + (6)$, so $a$ and $b$ actually are associates.  I figured that the author botched the example but that surely the basic fact must be true: if $R = \mathbb{Z}/(n)$ then there may be nonassociates $a,b \in R$ with $(a) = (b)$. However, I was not able to find a counterexample and eventually resorted to writing a computer program and found that there are no counterexamples in $\mathbb{Z}/(n)$ for $n \leq 100$.  So now I'm starting to think that there is no counterexample in $\mathbb{Z}/(n)$ at all, but I have not yet been able to prove this.  My questions:   If I am correct that $(a) = (b)$ in $\mathbb{Z}/(n)$ implies that $a$ and $b$ are associates, I would appreciate a nudge in the right direction toward a proof. (But if the proof is elementary, please give only a hint, not a solution :-) I'll post my solution once I have one. In either case, could you please point me to a genuine counterexample? If there is one in $\mathbb{Z}/(n)$ for some $n$, that would be ideal (no pun intended), otherwise a counterexample in any commutative ring with $1$ would be great. c stdout print without new line? If I look through the microwave window I can see through, which means visible radiation can get out. We know also that there is a mesh on the microwave window which prevents microwave from coming out.  My question is how does this work? how come making stripes or mesh of metals can attenuate microwave radiation yet allow visible radiation?  Looks like an electrodynamics problem to me with periodic boundary conditions (because of the partitions on the microwave oven window). Is it discussed in any textbook? You can reach this IP address  (if my computer is online). I want to assign a domain to it so I wonder how is that possible when I have no DNS? I do own my domain which is ".com". My IP is static.  Thanks What are the dangers of accepting gifts from unknown accounts on Steam? A user named 'steamfairy1' gifted me a game on Steam. I don't know this user, their profile shows no games, no friends and zero hours played. The profile of 'steamfairy1' was created the day I received the gift.  It very much looks like a scam, but I can't figure out how the scam is supposed to work. What's the worst thing that could happen if I accept the gift? Any idea what the trick here is? It could be just a random act of kindness and I'm just paranoid…  I contacted the Steam support, but they were unhelpful as usual: responding in the wrong language and with a canned one-liner that didn't make a whole lot of sense or had much to do with my question.  Keywords (not really tags, but I want this to be searchable): steamfairy, steam fairy Proof of inequality $2(\sqrt{n+1}-\sqrt{n}) < \frac{1}{\sqrt{n}} < 2(\sqrt{n} - \sqrt{n-1})$ using induction Prove that $2(\sqrt{n+1}-\sqrt{n}) &lt; \frac{1}{\sqrt{n}} &lt; 2(\sqrt{n} - \sqrt{n-1})$ if $n \ge 1$ using induction.  Can someone help me with this problem please. Base case is easily shown, and for the inductive step I know I have to use the inequality for $n\gt1$ to show that it is true for $n+1$, but I am not quite sure how to.   Thanks. What's the 'correct' way of registering/installing an Assembly to the GAC? Why is the product of all units of a finite field equal to $-1$? Suppose $F=\{0,a_1,\dots,a_{q-1}\}$ is a finite field with $q=p^n$ elements. I'm curious, why is the product of all elements of $F^\ast$ equal to $-1$? I know that $F^\ast$ is cyclic, say generated by $a$. Then the product in question can be written as  $$ a_1\cdots a_{q-1}=1\cdot a\cdot a^2\cdots a^{q-2}=a^{(q-2)(q-1)/2}. $$ However, I'm having trouble jumping from that product to $-1$. What is the key observation to make here? Thanks! Query Activity for ORDER BY xxx DESC LIMIT I'm trying to create a query activity in order to show, from a Data Extension, only the last 5 articles ids. I tried with the formula ORDER BY xxx DESC LIMIT 0,5 as in SQL but it is not working and it is returning this exception:     The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified   How can I use ORDER BY in a Data Extension?