I am new to java language and this my first time using scanner lib. I pretty sure I prevent null pointer happen in the method, but when I run the main, the stack trace says:     Exception in thread "main" java.lang.NullPointerException     at   Big_data_package.sort_test_main.readintoarr(sort_test_main.java:22)     at Big_data_package.sort_test_main.main(sort_test_main.java:60)   It happen on nextInt function on scanner method. could you guys help me point the error in my code? Thanks alot.  public class sort_test_main{  static File inputfile = new File("E:\\Java_workspace\\Big_Data_Sort\\io\\input.txt"); static mergeSort merge = new mergeSort(); static Scanner scanner; static int[] inputarr;  public static int[] readintoarr (int[] list, Scanner scanner) throws IOException{     int i = 0;     boolean endfile = false;      scanner = new Scanner(inputfile);          while(!endfile)         {             if(scanner.hasNextInt()){              list[i++] = scanner.nextInt();             }             else{                 endfile = true;             }         }         scanner.close();      return list; }// end of readintoarr  public static void arrtofile (int[]x) throws IOException{      File file = new File("E:\\Java_workspace\\Big_Data_Sort\\io\\output.txt");      // if file doesnt exists, then create it     if (!file.exists()) {         file.createNewFile();     }      BufferedWriter outputWriter = null;         outputWriter = new BufferedWriter(new FileWriter(file));       for (int i = 0; i &lt; x.length; i++) {         // Maybe:         outputWriter.write(x[i]+"");         // Or:         outputWriter.write(Integer.toString(x[i]));         outputWriter.newLine();       }       outputWriter.flush();         outputWriter.close();   }//end of arrtofile  //test public static void main(String[] args)throws IOException {      readintoarr(inputarr,scanner);     merge.mergeSort1(inputarr,0,inputarr.length);     arrtofile(inputarr);  }}
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 can I set a dark theme in TeXstudio? After perusing , I'm considering switching from TeXmaker (in which I use the preset "dark theme") to its fork, TeXstudio.  What I mean by "dark theme" is a dark background with suitable text colours, which, in my experience, is easier on the eyes than a bright background is. Here is an example:    TeXstudio doesn't seem to offer any preset dark theme, though, which means I have to customise all the colours/syntax-highlighting settings from scratch to get a dark theme even remotely usable. This can prove very time-consuming.   I'm aware this might sound a bit cheeky but,   if you are a long-time TeXstudio user, and you have fine-tuned the editor colours to get a visually pleasant dark theme,   please consider posting the relevant lines from your settings (.txsprofile or .tmxprofile) file as an answer below.  TeXstudio users who would like to use a dark theme could then build on your settings to fine-tune their own. How can I add the word "Chap" before the chapters numbers in the Toc in class report? At here  the word Chapter added in \documentclass{book}. Now I want to use them in \documentclass{report}. How can I do that? Unfortunately application has stopped android emulator genymotion Integral solutions of hyperboloid $x^2+y^2-z^2=1$ Are there integral solutions to the equation $x^2+y^2-z^2=1$? How to get a drive formatted with exfat working? Considering the irreducible (by condition) polynomial $f=X^4-2aX^2+b\in\mathbb Q[X]$ and the field extension $K=\mathbb Q(\sqrt{a^2-b})$ of $\mathbb Q$, I want to show the following result:    For $[L:\mathbb Q]=4$ we have $\sqrt b\in K$ where $L$ is the splitting field of $f$.   My thoughts so far: The four roots of $f$ are $\pm\sqrt{a\pm\sqrt{a^2-b}}$. If $L$ is of degree $4$ it must be primitive since $f$ is irreducible, so $L=\mathbb Q\left(\sqrt{a+\sqrt{a^2-b}}\right)$. Then, by multiplying the two roots $\sqrt{a+\sqrt{a^{2}-b}}\cdot\sqrt{a-\sqrt{a^{2}-b}}=\sqrt{b}$ we have that $\sqrt{b}\in L$. Now I want to look at $$\mathbb Q\subset K\subset K(\sqrt b)\subset L$$ and differentiate some cases. The case where $[L:K]=1$ is trivial and the case $[L:K]=4$ can't happen because if we square any root and subtract $a$, we get $\pm\sqrt{a^2-b}\in K$ which means $[L:K]\leq 2$. So let's look at the case where $[L:K]=2$. As I see it, we get two subcases:   For $[L:K(\sqrt b)]=2$ we have $K(\sqrt b)=K$ which finishes the proof. For $[L:K(\sqrt b)]=1$ we have $K(\sqrt b)=L$. This means that $L$ is also the splitting field of $(x^2-b)(x^2-(a^2-b))$. Is this a contradiction? How do I finish this case? Why do the Walking Dead Zombies only show intelligence in the very first episode? I enjoy The Walking Dead, however one question keeps nagging me. The 'Walkers' are always shown to not have any intelligence or memory of having been human. This is for all seasons except the very first one.  In the very first scene of Season One, Episode One, we see a little zombie girl stop to deliberately pick up a teddy bear from the ground.   Later in the same episode we see a zombie apparently try to turn the door knob to get into Morgen Jones' house.  Also at Atlanta they can climb fences and used rocks to break glass.  After season 1 I do not recall seeing any such intelligence demonstrated by a zombie again.  My question is: are these initial displays of intelligence a discrepancy in the story, or is there a plausible explanation why the Walkers performed these actions? OS X: Blurry Beamer presentations on Sierra / High Sierra Since OS X 10.12 (Sierra), the built-in Preview, but also many other PDF Viewers on OS X (such as Skim) show a number of problems, among them the following rendering issue:   The page is first rendered in low-res  with blurry text and graphics. About one second (!) later, the page is rendered in high fidelity. The display "wobbles", as text and graphics on the high-fidelity page is about one or two pixels up.   Example code:  \documentclass{beamer} \begin{document} \begin{frame}{Duke says}   \begin{itemize}   \item&lt;+-&gt; It don't mean a thing, if it ain't got that swing         \item&lt;+-&gt; (doo-ah, doo-ah, doo-ah, doo-ah, doo-ah, doo-ah, doo-ah, doo-ah)         \item&lt;+-&gt; It don't mean a thing all you got to do is sing         \item&lt;+-&gt; (doo-ah, doo-ah, doo-ah, doo-ah, doo-ah, doo-ah, doo-ah, doo-ah)  \end{itemize}  \end{frame}  \end{document}   While one may consider this acceptable when reading documents on screen, this is a show stopper for presenting beamer presentations with animations. The low-res display and wobbling makes the audience sick, while the 1 second rendering time makes PDF-based animations impossible.  So I am looking for a PDF Viewer for OS X that does not suffer this problems, but that a suitable for presenting beamer-based slide shows. Requirements:   page-wise full-screen/presenting mode with just the page and nothing else on the screen crisp and high-fidelity display quick rendering time   Unfortunately, the root of the problem is in Apple's own PDFKit library that is the base for most PDF viewers on OS X. So I am looking for PDF viewers that are not based on PDFKit, but fulfil the requirements above.  I am aware, of course, of Acrobat Reader DC. However, I do not particularly like its font rendering (Req 2) and I would also prefer something more light weight. I also have PDFExpert, which also is not PDFKit-based, however, does not support a presenting mode (Req 1). There are no book recommendations for Astrophysics here. I will write my own answer, but I am also interested in what are others' views on the question (I will NOT mark my own answer as the best one). When and where does Attack on Titan take place? Is the setting of "Attack on Titan" (Shingeki no kyojin) supposed to be Earth in the distant future and Titans suddenly appeared out of nowhere and devolved society to medieval level of technology? Or is this just a completely fictional setting? Personal Hotspot not working over Wi-Fi on iOS 13 After upgrade to iOS 13 from 12.4, I noticed that personal hotspot isn't working anymore over Wi-Fi (via USB is ok).  Tested on two computers with Win7. The PC can connect to Wi-Fi, but no valid IP (IPv4) is assigned and no connection is working to internet. "Each of these is" vs. "each of these are" Each of these CDFIs are finding solutions for communities that lack   access to traditional financial products and services, and the NEXT   Awards will accelerate their success.   OR     Each of these CDFIs is finding solutions for communities that lack   access to traditional financial products and services, and the NEXT   Awards will accelerate their success.   The difference is, the first one uses "CDFIs are" and the 2nd sentence uses "CDFIs is"  Which one is correct? Any why? Inno Setup: How to manipulate progress bar on Run section? How many squares on a 5-foot grid does a 5-foot radius spell affect? We had a situation come up regarding this term and how it affected spells.  In the spell Moonbeam, for example, it says a 5-foot radius cylinder appears. Does this mean that from the center of square it extends 2.5 feet into the next square hypothetically hitting up three squares or does this mean from the edge of one the target square to the five feet and five feet the other direction effectively covering only two squares for a total of 10 feet between total range of both squares?  I understand that radius means half the distance of a circle from the center point. The spell is not the issue but the understanding of radius as it pertains to the spell, as there are other spells that are worded similarly such as Fireball, etc.  Essentially we are asking, does the spell in the example effect one square or three? This would be saying the edge of the initial square is the point of origin and not the center of the square for the total distance of ten feet.  I had been working under the understanding that the radius is half of the distance and therefore dragging a ruler from the center of where I want the spell to take effect would get me the area of effect.  It's much easier to do this with Fireball, due to the larger area to effect, but this one has such a small area and therefore sparked the debate. We are using a grid system to mark the distance, etc. We play within the digital realm of roll20.com. Review sections to be always in the same place I find it not comfortable to have the order of the review sections changing all the time.  Within few seconds it changed from        to        Wouldn't it be better to have all of them in the same position, no matter the number of posts in each queue?  It assumes that the most important part is to lower the queue, although it is said there is no problem in having Close Votes with thousands of items. IMOH, most of us prefer going to one or other section (for example I like "Suggested edits") rather than to the queue with the most items, so having them changing their position makes it not that intuitive.  What do you think? Does it make sense to get a PhD if a person does not want to be in academia and prefers to stay in business? Reverse / invert a dictionary mapping Find and remove large files that are open but have been deleted How does one find large files that have been deleted but are still open in an application? How can one remove such a file, even though a process has it open?  The situation is that we are running a process that is filling up a log file at a terrific rate. I know the reason, and I can fix it. Until then, I would like to rm or empty the log file without shutting down the process.   Simply doing rm output.log removes only references to the file, but it continues to occupy space on disk until the process is terminated. Worse: after rming I now have no way to find where the file is or how big it is! Is there any way to find the file, and possibly empty it, even though it is still open in another process?  I specifically refer to Linux-based operating systems such as Debian or RHEL. Prove that for all integers $ a $ and $ b $, if $ a $ divides $ b $, then $ a^{2} $ divides $ b^{2} $. Accidentally moved directories under root