The program's objective is to print all the directories, sub-directories and files from the folder that we specify on the Client side. This program does that, but in the very end, it throws a NullPointerException. I use a recursive function to print the sub-dirs. The error is  Exception in thread &quot;main&quot; java.lang.NullPointerException at Client.main(Client.java:114)  Here is the Client-side program which deals with the listing try{     File maindir = new File(folder);                  if(maindir.exists() &amp;&amp; maindir.isDirectory())      {           // array for files and sub-directories            // of directory pointed by maindir           File arr[] = maindir.listFiles();            System.out.println(&quot;Files from main directory : &quot; + maindir);            // Calling recursive method           RecursivePrint(arr, 0);       } }  catch (NullPointerException e) {          System.out.println(&quot;NPE caught&quot;); }  Here is RecursivePrint static void RecursivePrint(File[] arr, int level)        {           // for-each loop for main directory files           for (File f : arr)            {               // tabs for internal levels               for (int i = 0; i &lt; level; i++)                   System.out.print(&quot;\t&quot;);                              if(f.isFile())                    System.out.println(f.getName());                               else if(f.isDirectory())                {                    System.out.println(&quot;[&quot; + f.getName() + &quot;]&quot;);                                   // recursion for sub-directories                   RecursivePrint(f.listFiles(), level + 1);               }           }      }  Can someone help me figure out why the NullPointerException occurs and how to resolve it?
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?
How to set English as default language instead of Tamil? The default language used in our laptop is Tamil. We don't know how to switch back to English. If we type something we are getting something.   We don't know the font name or version. Even the Menu bar and task bar contents are in Tamil. Add affiliations to the authors' name in the article class Recursively delete empty directories in Windows Where can I ask questions regarding Electronics? Can Clerics have divine power without it being provided by a god? Finding Maximum value of consecutive positive integers with constraints Let, $x,y,z$ be consecutive positive integers such that $\frac{1}{x} + \frac{1}{y} + \frac{1}{z} &gt; \frac{1}{10}$ I need to find the maximum value of $x+y+z$ ?  My attempt:  I tried guessing first, To maximise $x+y+z$ it is necessary to have high value for $x$, But not too high which will contradict the constrain of the problem. As we can roughly split the $0.1$ into three parts so I started with numbers closer to $30$ with trial an error I got that for $x=29$ we get the optimum and final result would be 90 (=max. value of $x+y+z$).   Is there any way to arrive at this conclusion with using inequalities? Any hints will be appreciated... I would that the images would appeared for each overlay. Eg, in overlay 1 I have img1.pdf, in overlay 2 I have img2.pdf, and in overlay 3 I have img3.pdf. How I do this?  \begin{center}   \begin{tikzpicture}     \node (img1) {\includegraphics[width=.5\linewidth]{img1.pdf}};     \pause     \node (img2) {\includegraphics[width=.5\linewidth]{img2.pdf}};     \pause     \node (img3) {\includegraphics[width=.5\linewidth]{img3.pdf}};   \end{tikzpicture} \end{center} Difference estimate & confidence intervals for $\chi^2$ test between 2 proportions I am using a chi-sq test between two proportions (). I am using this over the z-test for proportions because I do not think my data is normal.   My question is how do I get the difference (shift) estimate &amp; confidence intervals for this test.   For example,     Data1: 193/252=.77   Data2: 154/227=.68   P-value=.032 (I used the formula in the link above. I will also add my exact code below)  Shift Estimate: I assume its the difference between proportions, ie .77-.68=.09. Is this correct?   Confidence Interval: ??????????????????  Code for generating P-value (matlab):   % Pooled estimate of proportion  p0 = (n1+n2) / (N1+N2); % Expected counts under H0 (null hypothesis)  n10 = N1 * p0;  n20 = N2 * p0; % Chi-square test, by hand  observed = [n1 N1-n1 n2 N2-n2];  expected = [n10 N1-n10 n20 N2-n20];  chi2stat = sum((observed-expected).^2 ./ expected);  p = 1 - chi2cdf(chi2stat,1);  H=0; if(p&lt;.05), H=1; end How to link processing power of old computers together? Android - How to change color of an ScrollView/ListView Overscroll?(see Desc. for example) What are Alternative's "some" and "many" useful for? "In and of itself" is a phrase I find myself using all the time. But in and of itself, the phrase "in and of itself" has no meaning. That is, the individual words don't seem to contribute to the whole meaning of the phrase. Are Lorentz transformations linear transformations? My textbook says that Lorentz transformations are linear transformations and present them as matrices. Lorentz transformations relate different coordinate systems with each other. It seems that coordinate systems are linear spaces, but coordinates are just labels for spacetime points, with no other structures attached. So what is the linearity all about? How does vendor restocking work in Fallout 4? Prove that if 51 positive integers between 1 and 100 are chosen, then one of them must divide another. Given $51$ integers $a_1, a_2, \ldots, a_{51}$ satisfying $1 \leq a_i \leq 100$. Prove that there exist $i$ and $j$ such that $a_i \mid a_j$.   I'm a little unsure how to approach this problem. Thanks for any help. Why are the even and odd Regge trajectories degenerate? This is an old classic which I don't think ever got a clear answer. The Gribov-Froissart projection that gives the relativistic version of Regge trajectories treats even angular momentum differently from odd angular momentum. The trajectory functions in general are separate for even and odd angular momentum.  But in QCD, the odd trajectories interpolate the even trajectories in every case--- the two trajectories are degenerate. Is there a way of understanding why the even-odd trajectories are degenerate? Is is a symmetry argument? Can you find a natural system where they are not degenerate?  A quick google search revealed this reference, which doesn't answer the question, but gives an experimental signature for the degeneracy:  , There is probably excellent data by now on this. Foreign key constraint on array member? Suppose I have a table containing job roles:  CREATE TABLE roles (   "role" character varying(80) NOT NULL,   CONSTRAINT "role" PRIMARY KEY (role) );   Suppose I further have a table, users, and each row (a specific user) can have an arbitrary number of job roles:  CREATE TABLE users (   username character varying(12) NOT NULL,   roles character varying(80)[] NOT NULL,   CONSTRAINT username PRIMARY KEY (username) );   I should probably make sure that each member of users.roles[] exists in roles.role.  It seems to me that what I want is a foreign key constraint on each member of users.roles[] such that if references roles.role.  This doesn't seem possible with postgres.  Am I looking at this the wrong way?  What is the suggested "right" way to handle this? How can I use asymmetric encryption, such as RSA, to encrypt an arbitrary length of plaintext? Plotting an epicycloid Print total free memory from `free -m` free -m currently puts out something like this.     I would like to know using grep/awk how we can get the total free amount. i.e. 9083