I was using Java Eclipse and imported jsoup package, in order to scrape from the Amazon website.  The program simply goes to a search page, see the number of results and if any changes make notifications on the left side of the screen and constantly reload pages with a timer. Well it was working well and after a while, it shows me an error constantly. Sometimes it executes properly.    I have tried to use if(select=!null), but it shows me an empty result.  This means that selector sometimes scrapes data sometimes gets nulls.       package main;         import java.awt.AWTException;        import java.awt.SystemTray;        import java.io.IOException;        import java.net.MalformedURLException;         import org.jsoup.Jsoup;        import org.jsoup.nodes.Document;        import org.jsoup.nodes.Element;        import org.jsoup.select.Elements;        import java.util.Timer;         import java.util.TimerTask;        class amazon1 extends TimerTask{                public static int result1;                public static int result2;                public static int result3;          public void run() {            try {             final Document doc =          Jsoup.connect("http://www.amazon.com/s?k=hello&amp;i=stripbooks-intl-          ship&amp;ref=nb_sb_noss")                     .userAgent("Mozilla/17.0")                     .get()                      ;       Elements select = doc.select("div.a-section.a-spacing-                small.a-spacing-top-small&gt;span");             Element first = select.first();             String contentText = first.text();             amazon1.result1 =               Integer.parseInt(contentText.replaceAll("[\\D]",""));                 } catch (IOException e) {             // TODO Auto-generated catch block             e.printStackTrace();         }           //            if(amazon1.result1&gt;amazon1.result2) {         System.out.println(amazon1.result1);         amazon1.result2 = amazon1.result1;         amazon1.result3 = amazon1.result1 - amazon1.result2;            if (SystemTray.isSupported()) {                 DisplayTrayIcon td = new DisplayTrayIcon();                 try {                     td.displayTray();                 } catch (MalformedURLException | AWTException e) {                     // TODO Auto-generated catch block                     e.printStackTrace();                 }             } else {                 System.err.println("System tray not supported!");             }          } else {          ;         }             }     }         public class Main {        public static void main(String[] args) throws IOException {           Timer timer = new Timer();              TimerTask task = new amazon1();              timer.schedule(task, 3000, 5000);         }         }   Error is..       Exception in thread "Timer-0" java.lang.NullPointerException    at main.amazon1.run(Main.java:31)    at java.util.TimerThread.mainLoop(Timer.java:555)    at java.util.TimerThread.run(Timer.java:505)   NullPointer exception comes from selecting class element. The output should be 11620000 and notification from the right side of the screen.
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 difference between int.class and Integer.TYPE in java? Negative pressure How is negative pressure created in a fluid system?Isn't it counter intuitive that we are reducing the pressure of a system containing no molecules(zero pressure) to a lower value? Convex function as supremum of countably many affine functions Let $f:\mathbb{R}^n\to \mathbb{R}$ be a convex function. It is well-known that (see e.g.~) that there exists a set $A$ such that  $$ f(x)=\sup_{a\in A}A(a)x+b(a), \quad \forall x\in \mathbb{R}^n, $$ where $A(a)\in\mathbb{R}^{n\times n}$ and $b(a)\in \mathbb{R}^n$.  I was wondering, is there any reference saying we can choose $A$ as a countable set? I have just migrated from Windows environment. I have installed Python 3.2 in a separate directory. How can I get the python installation path in Ubuntu shell?  Is there any way I can let the shell know/choose at runtime which python version is to be used for further code execution?  Are there any environment variables and search path kind of things in Ubuntu Linux as well? Mavericks unusually high RAM usage I thought Mavericks was suppose to utilize RAM memory better, thus run smoother.  Running ML on Mac mini 2012, with 16GB RAM...always running smoothly even with over a dozen apps running.  Now, after installing Mavericks, my Mac is SLOW, eating up RAM like crazy! Looking over usage, of the 16GB of installed memory...on average it uses 10-14 GB RAM when barely running a few apps!!!   There is this kernel_task that is always running with over 1GB of RAM and most apps are not taking that much RAM, so what is using up all my RAM?! File cache? It shows very high in that new description, with about 1/3 of my total RAM The problem of instant velocity The concept of velocity is by definition the movement divided by the interval of time between initial position and final position.  If $f(t)$ is the position of a particle at time $t$; the velocity in the interval $[t_0;t_1]$ is $\dfrac{f(t_1)-f(t_0)}{t_1-t_0}$  The problem is that in a single instant there is no movement and the time is not changed; so no velocity.  I can consider $\lim_{t_1 \to t_0} \dfrac{f(t_1)-f(t_0)}{t_1-t_0}$, but mathematically it is only the limit of average velocity function and doesn't represent velocity at instant $t_0$  What are your views about this problem ? It has been a long time since I have used calculus, and I am trying to understand how the mean and variance of the Laplace distribution with pdf $$f(x|\mu,\sigma) = \dfrac{1}{2 \sigma}\,e^{-\Large\frac{|x-\mu |}\sigma}$$ are derived.  I know that E$[X] = \mu$ and Var$[X] = 2\sigma^2$, but I don't understand how that happens.   Many thanks. Problem from iOS 10.1.1 to 10.2.1.  I have no photos at all on my iPhone yet in settings it says my photo library is taking up ~200MB of space. The number of space being taken up keeps changing constantly(in the settings app on my phone). In iTunes, the storage bar at the bottom does(when in the sync menu) not show photos.           What is taking up this storage, and how can I reduce it?  Troubleshooting:   I disabled iCloud photo library and iCloud photo stream, still showing the same thing. Tried doing what @User9125 said, didn't work. I had set the date all the way back when I first got my phone, nothing showed up. Rebooting I had hundreds of photos in Whatsapp, I deleted them but I didn't get the storage back. It didn't even make a dent in the amount of storage being used by Photos so I don't think a third-party app could be taking up this storage. I don't think a system app is taking this space either, because I cleared the pictures in mail and messages. I tried using (through sideloading) in Secure Mode and Fast Mode, but it did not clear up the photos. How can I prove  from first principles that $0!$ is equal to $1$? Ubuntu Software doesn't open in Ubuntu 20.04 How can I handle autocorrelated residuals? In the Breusch-Godfrey test we use a model  $$ e_t = \varepsilon_t + \beta_1 \varepsilon_{t-1} + \dots+ \beta_p \varepsilon_{t-p}. $$  If we reject the null hypotesis of no serial auotocorrelation of the error, it means that the residuals follow an auto-regressive model of order ($p$).  If I want to avoid this problem, I must add a certain number of lags of the response variable $y$ as regressors in the original model. However, in some cases this method is not useful.   Are there other options to consider? Does Google use the Meta Description Tag for Description of Page? When you do a Google search, there is typically a snippet of sample content from the page. I seem to recall that the Meta Tags can influence this choice of descriptive sentences. Is that correct(?) and if so, is it the Meta Description Tag?  Also, how many characters is Google's descriptive sentences limited to? How do you transition from 1-page dungeon map to battle mat? I have a bunch of different ways I use to make maps for my tabletop game.  Sometimes I draw one on graph paper.  Sometimes I use .  Sometimes I copy a map from a published adventure or use the  random generators.  These all have the same output:  a piece of paper (or maybe two) with a map on it, and the map is usually quarter inch squares, or so.  When it's time to put minis on a mat, though, I need to copy over the relevant details of the map to our battle mat.  (We use Tact-Tiles.)  This is fine when most of our map is overland detail and I'm just copying down one or two rooms in which combat will occur.  For dungeon crawls, where there are more random encounters or where combat can chase through many rooms, it can lead to a pretty tedious drawing of the whole dungeon as we go.  I feel foolish for having to ask, but is there some trick, technique, or something to make it less tedious to transcribe maps from printed pages to the battle mat?  EDIT:  Answers in general are great, but I should note that the best answers, for me, will be informed by this previously-unmentioned fact:  the game venue is not my house, so I have limited prep time on site. Some guy called one of my Snipplr submissions "crap" because I used if ($_SERVER['REQUEST_METHOD'] == 'POST') instead of if ($_POST)  Checking the request method seems more correct to me because that's what I really want to do. Is there some operational difference between the two or is this just a code clarity issue? Should I upgrade my body or lens first? How to show that $2730\mid n^{13}-n\;\;\forall n\in\mathbb{N}$ Show that $2730\mid n^{13}-n,\;\;\forall n\in\mathbb{N}$   I tried, $2730=13\cdot5\cdot7\cdot3\cdot2$  We have $13\mid n^{13}-n$, by Fermat's Little Theorem.  We have $2\mid n^{13}-n$, by if $n$ even then $n^{13}-n$ too is even; if $n$ is odd $n^{13}-n$ is odd.  And the numbers $5$ and $7$, how to proceed? Apply display settings to all user accounts? Bijection between an open and a closed interval Recently, I answered to this problem:     Given $a&lt;b\in \mathbb{R}$, find explicitly a bijection $f(x)$ from   $]a,b[$ to $[a,b]$.   using an "iterative construction" (see below the rule).  My question is: is it possible to solve the problem finding a less exotic function?  I mean: I know such a bijection cannot be monotone, nor globally continuous; but my $f(x)$ has a lot of jumps... Hence, can one do without so many discontinuities?    W.l.o.g. assume $a=-1$ and $b=1$ (the general case can be handled by translation and rescaling). Let:  (1) $X_0:=]-1,-\frac{1}{2}] \cup [\frac{1}{2} ,1[$, and  (2) $f_0(x):=\begin{cases}     -x-\frac{3}{2} &amp;\text{, if } -1&lt;x\leq -\frac{1}{2} \\ -x+\frac{3}{2} &amp;\text{,     if } \frac{1}{2}\leq     x&lt;1\\ 0 &amp;\text{, otherwise} \end{cases}$,  so that the graph of $f_0(x)$ is made of two segments (parallel to the line $y=x$) and one segment laying on the $x$ axis; then define by induction:  (3) $X_{n+1}:=\frac{1}{2} X_n$, and  (4) $f_{n+1}(x):= \frac{1}{2} f_n(2 x)$  for $n\in \mathbb{N}$ (hence $X_n=\frac{1}{2^n} X_0$ and $f_n=\frac{1}{2^n} f_0(2^n x)$).  Then the function $f:]-1,1[\to \mathbb{R}$:  (5) $f(x):=\sum_{n=0}^{+\infty} f_n(x)$  is a bijection from $]-1,1[$ to $[-1,1]$.  Proof: i. First of all, note that $\{ X_n\}_{n\in \mathbb{N}}$ is a pairwise disjoint covering of $]-1,1[\setminus \{ 0\}$. Moreover the range of each $f_n(x)$ is $f_n(]-1,1[)=[-\frac{1}{2^n}, -\frac{1}{2^{n+1}}[\cup \{ 0\} \cup ]\frac{1}{2^{n+1}}, \frac{1}{2^n}]$.  ii. Let $x\in ]-1,1[$. If $x=0$, then $f(x)=0$ by (5). If $x\neq 0$, then there exists only one $\nu\in \mathbb{N}$ s.t. $x\in X_\nu$, hence $f(x)=f_\nu (x)$. Therefore $f(x)$ is well defined.  iii. By i and ii, $f(x)\lesseqgtr 0$ for $x\lesseqgtr 0$ and the range of $f(x)$ is:  $f(]-1,1[)=\bigcup_{n\in \mathbb{N}} f(]-1,1[) =[-1,1]$,  therefore $f(x)$ is surjective.  iv. On the other hand, if $x\neq y \in ]-1,1[$, then: if there exists $\nu \in \mathbb{N}$ s.t. $x,y\in X_\nu$, then $f(x)=f_\nu (x)\neq f_\nu (y)=f(y)$ (for $f_\nu (x)$ restrited to $X_\nu$ is injective); if $x\in X_\nu$ and $y\in X_\mu$, then $f(x)=f_\nu (x)\neq f_\mu(y)=f(y)$ (for the restriction of $f_\nu (x)$ to $X_\nu$ and of $f_\mu(x)$ to $X_\mu$ have disjoint ranges); finally if $x=0\neq y$, then $f(x)=0\neq f(y)$ (because of ii). Therefore $f(x)$ is injective, hence a bijection between $]-1,1[$ and $[-1,1]$. $\square$ Proving the convergence of $\sum\limits_{n=1}^{\infty}\frac{1}{1+z^n}$ for $|z| > 1$ $\sum\limits_{n=1}^{\infty}\frac{1}{1+z^n}$, $|z|&gt;1$.  There are two facts that my professor uses that I am confused about.  The first is: $|1+z^n| \geq ||z|^n-1|$, I believe this is true for any $|z|$.  The other is: $\frac{1}{|z|^n-1} \leq \frac{2}{|z|^n}$, I believe this is also true for any $|z|$.  Can anyone prove these statements for me? My laptop's cable broke and sadly it seems like I need to buy a new power supply.  What I wonder is, I've found that universal power supplies are much cheaper than the official HP ones. Are they really worth it?  Another question: the original supply has these specs: 65W, 18.5V, 3.5A. However the universal supplies are more powerful (90W, 100W) and come in integer voltages (17V, 18V, 19V, etc). Are they compatible? Should I set them to 18V or 19V?