I want to try to put a rectangle on my screen by using JPanel and JFrame. But I get the java.lang.NullPointerException and I don't know why. My code:  Class to create a rectangle:  package com.game.main;  import java.awt.Color; import java.awt.Graphics;  import javax.swing.JPanel;  public class Rect extends JPanel {  Graphics a;  public Rect(){           a.drawRect(100, 100, 200, 250);     a.setColor(Color.RED);     a.fillRect(100, 100, 200, 250);          } }   Class to create a JPanel:  package com.game.main;  import javax.swing.JPanel;  public class Inside extends JPanel {      public Inside(){         JPanel content = new JPanel();         Rect rect = new Rect();         content.add(rect);     } }   Class to create a JFrame:  package com.game.main;  import javax.swing.JFrame; import javax.swing.JPanel;  public class Window extends Main{      public static final int Width = 1020, Height = 860;      public Window(JPanel content){         JFrame frame = new JFrame("The Game");         frame.setContentPane(content);         frame.setSize(Width, Height);         frame.setVisible(true);         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         frame.setLocation(100, 100);     }  }   Class to put everything together:  package com.game.main;  public class Main {      public static void main(String[] args) {         Inside inside = new Inside();         Window window = new Window(inside);     }  }   I am also not very familiar with the Graphics class, so a little bit of explanation would be wonderful.  Thank you
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?
Is there a conventional wisdom to what gear a bike should be left in, when used infrequently? Under Wild Shape it says "assume the shape of a beast" you have seen before. Does this mean they can only transform into creatures that have the beast type, such as bear, wolf, crocodile, etc.? Or can they turn into things with other types, like dragon, monstrosity, humanoid, fiend, etc.? Normally, it takes three votes to delete.  It still does, though the mouseover tip for a question with one delete vote cast on it already appears to be stuck at '1'    And then after casting a delete vote on it:    And if I've cast the first delete vote:    The above examples are from P.SE, and while I don't have the privs to verify this being the situation on other sites, this has been confirmed on at least SO and is likely network wide.    Child meta dups:   SO: Traditional search-as-you-type on newer Nautilus versions Why is the speed of light defined as 299792458 m/s? Why is the speed of light defined as $299792458$ $m/s$? Why did they choose that number and no other number?  Or phrased differently:  Why is a metre $1/299792458$ of the distance light travels in a sec in a vacuum? How do I put text over symbols? Can I completely disable Cortana on Windows 10? Why is the gap between the translation and the last line of the gloss so wide in my interlinear gloss? Is it possible to overload the null-coalescing operator for a class in C#?    Say for example I want to return a default value if an instance is null and return the instance if it's not. The code would look like something like this:     return instance ?? new MyClass("Default");     But what if I would like to use the null-coalescing operator to also check if the MyClass.MyValue is set? Hadamard Product of $e^z-1$ Assuming the formulas $$\sin(z)=\frac{e^{iz}-e^{-iz}}{2i}\quad\text{and}\quad\frac{\sin(\pi z)}{\pi z}=\prod_{n=1}^\infty\left(1-\frac{z^2}{n^2}\right),$$ I want to find the Hadamard product of $e^z-1$. I think I've done the work correctly, but I end up having an extra factor of $2\pi i$ at the end (this is from Stein and Shakarchi's book and they list the answer for this particular problem). So, my work is \begin{align} e^z-1&amp;=e^{z/2}\left(e^{z/2}-e^{-z/2}\right)\\ \\ &amp;=e^{z/2}\left(e^{i(-iz/2)}-e^{-i(-iz/2)}\right)\\ \\ &amp;=2ie^{z/2}\left(\frac{e^{i(-iz/2)}-e^{-i(-iz/2)}}{2i}\right)\\ \\ &amp;=2ie^{z/2}\sin(-iz/2)\\ \\ &amp;=2\pi i ze^{z/2}\frac{\sin(-iz/2)}{\pi z}\\ \\ &amp;=2\pi i ze^{z/2}\frac{\sin\left(\pi(\frac{-iz}{2\pi})\right)}{\pi z}\tag{*}\\ \\ &amp;=2\pi i ze^{z/2}\prod_{n=1}^\infty\left(1-\frac{\left(\frac{-iz}{2\pi}\right)^2}{n^2}\right)\\ \\ &amp;=2\pi i ze^{z/2}\prod_{n=1}^\infty\left(1+\frac{z^2}{4n^2\pi^2}\right). \end{align}  The answer according to the book is $$e^z-1=e^{z/2}z\prod_{n=1}^\infty\left(1+\frac{z^2}{4n^2\pi^2}\right).$$Have I made a simple mistake in calculation, or are the two somehow compatible with each other?  Update: Thomas Andrews has pointed out a mistake in my infinite product formula. I've corrected that mistake.  $(*)$ The error occurs from this line to the next. Instead of multiplying and dividing by $z$, I should have multiplied and divided by $\frac{-iz}{2\pi}$. That would cause the appropriate cancellation. How to check the count of .txt files in a folder (dir command)? How can use dir command to check how many .txt files there are in a folder (for example,  C:\Temp\)? The prime example is C# and .Net. 95% of C# questions are also tagged .Net. The reverse isn't the case so it's not a synonym. Basically, C# is a child of .Net.  Would it be possible to create some sort of one-way linkage like this? I received an email saying documents are /were I keep getting the message MobileMe Service Stopped Working each time I open Outlook 2007. I have to click on the Close Program button in the error message twice each time it shows up while Outlook is trying to load up. Then I am able to use Outlook. I never use my iCloud account and would like to know how I can deactivate iCloud so I do not have issues with my Outlook. The text for  says:     {1}{G}, {T} : Target creature you control fights another target creature. (Each deals damage equal to its power to the other.)   Does this have anything to do with combat? Or is it just direct damage between two creatures? For example, can one of the creatures have defender? Or what if one of them is tapped?   I've been assuming it is more like the damage dealt by a .  Also: are the two creatures then “tapped” until their next untap step? ie: could you use Ulenvald Tracker to make two creatures fight in your pre-combat step, then enter the combat phase with a creature who just “fought” untapped? Could you make two creatures fight who are both tapped? Question about the Riemann-Lebesgue Lemma proof Ok, so one of the formulations of the Riemann-Lebesgue Lemma says: $$ f\in L^1(\mathbb{R}) \implies \hat{f}(\omega)\to 0\;\mbox{ when } \;|\omega|\to\infty.$$  I get all the steps of the proof, except the one which says that if $f$ is an arbitrary integrable function, it may be approximated in the $L^1$ norm by a compactly supported smooth function $g\in L^1$. My question is: Why? How do you know that for all $\epsilon&gt;0$, and for all arbitrary function $f\in L^1$ exists a compactly supported smooth function $g$ so that $||f-g||_{L^1}&lt;\epsilon$? The "proof" can be found in many places, but this step can be found in Wikipedia How do I print a double value with full precision using cout? In my  I was printing a double using cout that got rounded when I wasn't expecting it.  How can I make cout print a double using full precision? Why are `/dev/ptmx` and `/dev/pts/ptmx` not device files? says     On Linux, using devpts, there is no master device file. The process on the master end uses a file descriptor, which it gets by opening ptmx, but there’s no corresponding device node.   Did the author refer to /dev/ptmx or /dev/pts/ptmx?    Why are /dev/ptmx and /dev/pts/ptmx not device files? What types of files are they?  What is the difference between /dev/ptmx and /dev/pts/ptmx?  Thanks.  On Lubuntu 18.04  $ file /dev/ptmx  /dev/ptmx: character special (5/2) $ file /dev/pts/ptmx  /dev/pts/ptmx: character special (5/2)  $ sudo su  # stat -L /dev/fd/3 3&lt;&gt; /dev/pts/ptmx   File: /dev/fd/3   Size: 0           Blocks: 0          IO Block: 1024   character special file Device: 15h/21d Inode: 2           Links: 1     Device type: 5,2 Access: (0000/c---------)  Uid: (    0/    root)   Gid: (    0/    root) Access: 2018-11-21 13:39:10.544000218 -0500 Modify: 2018-11-21 13:39:10.544000218 -0500 Change: 2018-11-21 13:39:10.544000218 -0500  Birth: -  # stat -L /dev/fd/3 3&lt;&gt; /dev/ptmx   File: /dev/fd/3   Size: 0           Blocks: 0          IO Block: 4096   character special file Device: 6h/6d   Inode: 87          Links: 1     Device type: 5,2 Access: (0666/crw-rw-rw-)  Uid: (    0/    root)   Gid: (    5/     tty) Access: 2019-01-06 07:19:54.372098540 -0500 Modify: 2019-01-06 07:19:54.372098540 -0500 Change: 2018-11-21 13:39:30.372098540 -0500  Birth: - How do I improve boot speed? I have seen many videos that make Ubuntu faster, but these methods only make desktop performance faster.  I am looking to make my computer boot faster. Is their anything I can do to make Ubuntu boot significantly faster? What is $48\div2(9+3)$?