MyImg.java  import java.awt.Graphics2D;  import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import java.io.IOException; import java.io.File;  public class MyImg {      private BufferedImage img;     private int x,y;      public MyImg( String imageFileName, int x, int y)  {         this.x = x;         this.y = y;          try{             img = ImageIO.read(new File(imageFileName));          } catch  (IOException e) {           }     }      public void paint(Graphics2D g) {         g.drawImage(img, x, y, img.getWidth(), img.getHeight(), null);       }  }   Frametester.java  import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame;   /**    This program demonstrates how to install an action listener. */ public class FrameTester {       public static void main(String[] args)     {           JFrame frame = new JFrame();          DrawImageTester theImgTester = new DrawImageTester();          frame.add(theImgTester);           frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         frame.setVisible(true);     }      private static final int FRAME_WIDTH = 500;     private static final int FRAME_HEIGHT = 600; }   DrawImageTester.java  import java.awt.Graphics2D;  import java.awt.Graphics;  import javax.swing.JComponent;  public class DrawImageTester extends JComponent{     private MyImg img1, img2;      public DrawImageTester() {         img1 = new MyImg(Definition.IMG_BG_BLACK, 100, 100 );         img2 = new MyImg(Definition.IMG_BG_WHITE, 200, 100);     }      public void paint(Graphics h) {         Graphics2D g = (Graphics2D)h;          img1.paint(g);           img2.paint(g);      } }   Definition.java  public class Definition{     final public static String IMG_BG_BLACK = "image/black.PNG";     final public static String IMG_BG_WHITE = "image/white.PNG";      final public static String IMG_KNIGHT_BLACK = "image/bKn.png"; }      When I run FrameTester.java, I get the error:  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException     at MyImg.paint(MyImg.java:27)     at DrawImageTester.paint(DrawImageTester.java:17)   The problem lies within this line:  public void paint(Graphics2D g) {     g.drawImage(img, x, y, img.getWidth(), img.getHeight(), null);   }   I think this is caused by an object not being initialized. I am pretty sure img is initialized. img is declared in MyImg.java, the MyImg object is created in the DrawImageTester.java class. The DrawImageTester object is created inside main. Both x, and y, have values, and getWidth, and getHeight are methods of the BufferedImage class. Can anyone lend me some help?
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 difference between these two Breusch-Pagan Tests? Why is "night" spelled with "gh"? How to check if list item already exist when adding it with iOS: Compare two dates What does the '=>' syntax in C# mean? Why can't an enum value be fully qualified in a switch statement? How to SEO a Single-Page website Suppose that $f$ is differentiable on $\mathbb{R}$ and $\lim_{x\to \infty}f'(x)=M$. Show that $\lim_{x\to \infty}f(x+1)-f(x)$ exists and find it. I've been stuck on this question for a long time now and was wondering if anyone could show me how it's done. So far I have done the following: Since $\lim_{x\to \infty}f'(x)=M$ then $\forall \epsilon ,\exists A &gt;0$  s.t. if $x&gt;A$ then $|f'(x)-M|&lt;\epsilon$. So we have that $M-\epsilon&lt;f'(x)&lt;M+\epsilon$. By MVT on $[x,x+1]$ for $x&gt;A$, $\exists c\in (x,x+1)$ s.t. ${f(x+1)-f(x)\over 1}=f'(c)$. Therefore, $M-\epsilon&lt;f(x+1)-f(x)&lt;M+\epsilon$. However, I do not know what to do after this. How to link data to a polygon ArcMap 10.3 I have a map with different polygons (118). Each of this polygons represent diferent vegetation types.  For each of those polygons I have data of which species there is and how abundant they are (the abundance is measured with a scale from 1 to 3).  I would like to "link" (I am sorry if its not the correct way of name it) the data of which species and abundance there is in each of those polygons.   I would like afterwards to be able of selecting the different polygons containing the same abundance and species.  In the polygons I created there is no atributes associated other than (FID, shape and Id. the 3 of them created alone by the program when I drew them) and the tables I have in excel with the data I want to "link" to the polygons contain a column called species and another abundance.  As you can see, I'm pretty new using the program...    As I have tried to do what you all suggest in the comments down here, and I couldn't achieve what I was wanting to do (provably because of my bad explanation before...)  I leave a picture:  As you can see in the attribute table, that is how every attribute table of each polygon (which represents one area) looks like. On the right there is how I have my data in excel. Could you please suggest something I could do in order to add to the polygons attribute table the data belonging of species and its abundances (polygon number 1 has to have all the species (Acer mons, Acer pseu, Acer repens….) and its abundance (which are the numbers of the row Area1). I was given this question by a friend and after working tirelessly on it I have not come up with anything substantial. I was hoping someone in the community could provide a pointer or possibly a solution. The person who gave me the question says he has the answer to it, but I am more curious about the working.  Here is the question:     Three points $(B, C, D)$ lie on parabola  $y = x^2$ and a fourth point $A$ is placed such that $ABCD$ forms a square. Find the minimal area of $ABCD$.   So far my working out has involved a collection of distance/mid-point formula's and I haven't even reached the point where I differentiate to minimize the area.  Any pointers would be welcome.   Edit  Apparently the correct answer is $\sqrt{2}$ units squared. How to sort an array of integers correctly If a blocking creature leaves the battlefield, is the attacker still blocked, or will it damage the opponent? Suppose Player 1 has a Dragon on the table and  in hand, while Player 2 has two Spiders on the table.  Player 1 chooses to attack with the Dragon and Player 2 chooses to block with one of the Spiders.  Before combat damage is to be dealt, Player 1 uses Unsummon on the blocking Spider.    Does Player 2 take any life damage from the attacking Dragon? How do I put text over symbols? Algorithm over 2 pages I am writing a few rather large pseudocode functions using algorithm and algorithmic, i.e. my code looks something like:  \begin{algorithm}                      \caption{Coolest Algorithm ever}           \label{findme}                           \begin{algorithmic} [1]                   % enter the algorithmic environment \REQUIRE    Here are a few variables \\             variable 2 \\             variable 3  \ENSURE     this is the output \\             output 2  \STATE $some cool code here$ \STATE $some cool code here$ \STATE $some cool code here$ \STATE $some cool code here$ \end{algorithmic} \end{algorithm}   Unfortunately this code does not fit on one page and I am definitely not able to split it into some subfunctions or so (I already did that as far as possible).  So now I need to split up the algorithm into two pages, but I have no idea how.  The easiest way I can imagine is just to start a new algorithm on the new page, but this time letting the line counter start at line 35 or so instead of 1. But how can I do that?  Please not that there is already a similar question here on this site, but it deals with the package algorithmicx. Where are my installed applications? Virtualbox Windows 10 Guest installation is freezing up in 14.04 I've installed VirtualBox using the Software Centre and I'm running a system on Ubuntu 14.04 with 8gb RAM, 64-bit dual core processor.  I want to run Windows 10, I've tried both 64 and 32 bit versions, in virtualbox. However, every time I start up windows 10 it gets to the point where the dots go round in a circle, then it freezes up and crashes back to the virtualbox manager. The only information it gives me is that the virtual machine was aborted.  I've changed the settings around a lot and nothing is working.  Any help would be appreciated.  Oh, and I've run Windows 10 technical preview on this machine before, a while ago  Thanks for any help in advance. Project Euler Question 14 (Collatz Problem) Take a look at this example schematic:  The chip in question is the  and as you can see power is provided on both sides (with a 100nF cap to smooth noise I guess). Is this strictly required or could you put power into one side and just ignore the other? I know that I have just put power in one side and everything still seems to work fine but I feel uneasy with doing that. I feel that they would not waste pins that could be doing something useful by having an extra pair of power in/out pins. For what purpose does this PIC MCU (and others like it) have multiple power pins? Hard disk file system is shown as Raw file system; how can I access it? How do I test if all minecraft players on a server are in a radius? This has got me. I need a command that tells me if all players on a server are in a radius of a command block. If one of them isn't in the radius, the command will be false. Any ideas? Thanks!