I'm getting a NullPointerException when trying to add a new instance of a Block class to an ArrayList called blocks.  Here is the code snippet containing the line of error:  public class Level1State extends GameState {      private Player player;     private ArrayList&lt;Block&gt; blocks;      public Level1State(GameStateManager gsm) {         super(gsm);         this.blocks = new ArrayList&lt;Block&gt;();     }      @Override     public void init() {         player = new Player(30, 30);          blocks.add(new Block(500, 400));     }     ... }   And the Block class is very simple:  public class Block extends Rectangle {     private static final long serialVersionUID = 1L;      public static final int blockSize = 64;      public Block(int x, int y) {         setBounds(x,y,blockSize,blockSize);     }      public void tick() {      }      public void draw(Graphics g) {         g.setColor(Color.DARK_GRAY);         g.fillRect(x - (int) GameState.xOffset, y - (int) GameState.yOffset,                 width,                 height);     } }   Any help is 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?
Solve this integral for free WiFi Detect the Internet connection is offline? How to detect the Internet connection is offline in JavaScript? Why are the dineutron and diproton unbound? How is Anti Aliasing Implemented in Ray Tracing? After reading a few articles online I can confidently say I am clueless on how Anti-Aliasing works when using Ray Tracing.  All I understand is that A Single Pixel/Ray is split into 4 sub-pixels and 4 rays rather than 1.  Could somebody please explain how this is done (preferably with code)? Why does hair grow after trimming but remains at a constant length after a while? Some hair especially body hair regrows after trimming but stops growing after a while. What is the mechanism behind control of hair growth and how is the length limit determined? How to understand the Ubuntu file system layout? In Windows there’re perhaps only a couple of important folders (by important I mean important in my logical picture of the Windows file system) in the installation drive (in my case C:\). Namely Program Files and Windows. I simply stay away from Windows folder and the “add remove program files” is good enough to handle the program files folder of Windows. Of course there’s a folder named Users where the users (who are not admins) can access only their folders.  Thus there’s a clear picture at some level in my mind of the Windows file system. In Ubuntu, when I reach the location /, there’s a huge list of folders, most of which I have no clue as to what they contain. The /bin folder seems to be the equivalent of the Windows folder in windows. The /usr folder seems like it’s the equivalent of the Users folder in Windows. But even the /home folder looks like it can fit the bill.  Please understand that I do understand, that Ubuntu (Linux) has a different character than that of Windows, i.e., there need not be exact equivalent of Windows functions, in Ubuntu. All I am looking for is a bit more clearer picture of the Ubuntu file system.   This question is a part of a bigger question which I am splitting up to make it more answerable. The original question can be found here: Must an uncountable subset of R have uncountably many accumulation points? How to solve this probability problem analytically (instead of using simulation)? Probability of Bill wins the game if he goes first I see lots of tutorials telling me how to root my phone (Motorola Droid), but none of them mention any potential "side effects."  Aside from a few relatively minor issues that seem to require rooting to fix, I'm basically happy with the phone and therefore a little leery of messing with a device that cost me a lot of money and is only a few months old.  Assuming that I'm just talking about rooting, and none of the typical post-root actions (like installing a custom ROM), am I taking any risks by choosing to root?   Does it have the potential to brick the device? Will it void my warranty? Will I stop getting updates? Will the cops show up at my front door the next day? (Yes, I'm being facetious.) Anything else I should be aware of?   (See also: ) Remove particularly tricky items from context menu I've found various sources of info about removing these annoying things which I never use... but I haven't succeeded in getting rid of the following.    (Avira-related:) - Scan selected files with Avira  (I believe all this is M$ crapware... I presume it's all been lovingly crafted so they're all impossible to remove. You never know, though: some super-uber-uber-geek might just have found a way) - Restore previous versions  - Cut - Copy - Delete  - Rename Biblatex: Don't show n.d. when no year is given I am using biblatex/biber with several bibliographies for my book, and the misc-type, which is also a single bibliography (as a chapter), for legal documents. These documents often do not have a proper date or rather the date is part of the title. However, Latex gives me a "n.d." output, and I am wondering what I can do for it to not give a "n.d." when there is no year given?    To make clear, the reason for why I don't want to use the "year" field is that I deal with very different kinds of documents, which may either have no date or the date is in the title, because of which I prefer to simply "hard-copy" the whole thing in the "howpublished"-section and need to suppress the year, if none is provided.  MWE:  \usepackage[autocite=footnote, language=german, style=authoryear-ibid, sorting=nyt, backend=biber]{biblatex} \usepackage[bottom]{footmisc} \bibliography{lit.bib} \makeindex \begin{document}  Test\autocite[2]{draftnotice}.  \printbibliography[title={EU Legal Documents}, type=misc1]  \end{document}   My lit.bib is as follows:  @misc1{draftnotice,     Author = {{COMMUNICATION FROM THE COMMISSION}},     Howpublished = {Draft Commission Notice of 2014 on the notion of State aid pursuant to Article 107 (1) TFEU}}   Check out my MWE on overleaf Taylor series expansion for $f(x)=\sqrt{x}$ for $a=1$ avoid space after commas used as thousands separator in math mode Setting the pivot point of an object I have a sword that currently rotates around a pivot point thats off of the actual object. Im new to blender and im not sure how i would go about changing it so that the sword rotates around the handle. Any help would be appreciated! how to change the distance between tick mark and tick label I consistently have more than one terminal open. Anywhere from two to ten, doing various bits and bobs. Now let's say I restart and open up another set of terminals. Some remember certain things, some forget.  I want a history that:   Remembers everything from every terminal Is instantly accessible from every terminal (eg if I ls in one, switch to another already-running terminal and then press up, ls shows up) Doesn't forget command if there are spaces at the front of the command.   Anything I can do to make bash work more like that? How far does a rogue move when dashing twice using Cunning Action? A rogue receives a bonus Cunning Action, and one option is to Dash. My understanding is a Dash allows a player to move up to twice his speed for his turn.  If a rogue is using a regular action to Dash (hence, is already dashing) can he also use his cunning action as a bonus to Dash again — effectively moving 4 times normal speed in a turn? Why is the comma splice an error? It's always drilled into us that we shouldn't use comma splices. They're bad, to be avoided and poor form.  But why? What makes the comma a faulty choice in something like this:     I never liked school, it was boring and repetitive most of the time.   It could be replaced with a semicolon, dash, period or colon and be "correct." Yet to a fair amount of people, the comma seems fine. If it weren't, it wouldn't be found so often in online forums, text messages, emails and so on.  What makes the comma between two sentences an error? Expected value of x in a normal distribution, GIVEN that it is below a certain value Eclipse Scala IDE - class file needed by X is missing