I've gotta create a bst and read in a text file to it so that the words of the file are recorded into that bst. I have to print the frequencies and probabilities of each word being searched however when i run my code i get an exception and I'm not really sure why. It's something having to do with my insert method I think. Here's my code:  import java.util.*; class Lepep3{     node root;     int counter;  class node{     String word;     int frequency;  //how many times the word shows up in the text file being read into the BST     double probability; //the probability that the node will be searched for      node leftLink, rightLink;   node(String w){         String word = w;         int frequency = 1;         node leftLink = null;         node rightLink = null;       }  }  Lepep3(){     root = null; }  void insert(String w){     if(root == null ){         root = new node(w);     }      else{         insert(w, root);     } }  void insert(String w, node t){     node parent = t;     while(t != null){         parent = t;         if(t.word.equals(w)){             t.frequency++;             return;         }          else if (w.compareTo(t.word) &lt; 0)             t = t.leftLink;         else             t = t.rightLink;     }     if(w.compareTo(parent.word) &lt; 0)         parent.leftLink = new node(w);     else          parent.rightLink = new node(w); }  void readInput(){     String x;     counter = 0;     Scanner inf = new Scanner(System.in);     while(inf.hasNext()){         x = inf.next();         insert(x);         counter++;     } }  double getProbability(node n){     double temp = n.frequency;     temp = temp/counter;      return temp; }  void printNodes(){     printNodes(root); }  void printNodes(node r){     if(root == null)         return;     printNodes(r.leftLink);     System.out.print(r.word + "   " + r.frequency + "   \n");     System.out.printf("%.4f\n", getProbability(r));     printNodes(r.rightLink); }  public static void main(String[] args) { System.out.print("\n Program to: find the frequency and probability of words form a given test file.");   System.out.print("\n Prepared by Lepe, Alfredo, Student ID: 109698093.");   System.out.print("\n Date: 3/8/2020");  Lepep3 ject = new Lepep3();  ject.readInput();  System.out.print("word   frequency   probability\n"); ject.printNodes(); }   }  Here's what my command prompt prints when i run the code:  C:\School\comp 282>java Lepep3 &lt; p3.txt  Program to: find the frequency and probability of words from a given file.  Prepared by Lepe, Alfredo, Student ID: 109698093.  Date: 3/8/2020  Exception in thread "main" java.lang.NullPointerException      at Lepep3.insert(Lepep3.java:38)      at Lepep3.insert(Lepep3.java:31)      at Lepep3.readInput(Lepep3.java:58)      at Lepep3.main(Lepep3.java:88)
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?
Site-specific spellcheck? I often see misspelled words in titles and bodies of questions, only to see them spelled properly in the tags. I have to imagine that tags are always spelled right because it's hard to type arbitrary text into the tag box. I also have to imagine that sometimes autocorrect and spellcheck provided by browsers tend to turn programming terms and package names into English words. For example, see   Would it be possible to have some sort of spellchecker that compares text of titles (and maybe bodies) to known tags and offers some sort of correction (maybe red squiggles or something) when there's some statistical probability of a misspelling?  Since this would be using a site's tags, "magneto" would get corrected to "magento" on SO, while "magento" would get corrected to "magneto" on aviation.stackexchange.com.  In theory this could reduce a lot of stupid typos and prevent trivial edits just to fix the spelling of key words.  Note that this is not solving a problem that a user's browser can already solve because browsers ship with English dictionaries, not dictionaries of programming terms. In fact, it's potentially correcting a problem created by the browser (which might have already autocorrected "magento" to "magneto"). Given a sample of n units out of a population of N, population median can be estimated by the sample median.  How can we get the variance of this estimator? Application of Kirchhoff's laws in circuits with inductors As we know, the  are applicable for conservative electric fields. Now it is applicable for circuits where inductors are present but the field there is not .  So how are the  Kirchhoff's laws  applicable there? Ohmic Heating in Wires please could someone tell me why Ohmic losses are always referred to as $I^2 R$ losses? Here is my problem. If the power coming from a power station is fixed then you can either deliver this power as high voltage, low current or high current, low voltage. But isn't $I^2R$ equal to $V^2 / R$, therefore if R is constant doesn't the power depend on the square of the voltage so surely it doesn't matter whether it is high voltage or high current. The only way I can reconcile this is that a high current must cause a greater heating effect than a high voltage. I can't figure why though. If this is the case then is there a reason why a high current causes more heating than a high voltage? When to pull loose teeth My 5 year old is starting to have some teeth become loose. Specifically her lower two front teeth. I just noticed today that one of them is really loose. However, I don't know how loose it should be before pulling it out.  I'm also curious about how to pull them (or should I just let them fall out, which seems bad). My father pulled mine with pliers but I think my wife would freak out if I tried to do that.  So, how loose is lose enough and how to pull them out (technique, tools, etc.). Proving that $\left( \frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2} \right) \lvert f(z) \rvert^2 = 4 \lvert f'(z) \rvert^2$ Given $f$ entire show that $$ \left( \frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2} \right) \lvert f(z) \rvert^2 = 4 \lvert f'(z) \rvert^2 $$ I've come close to getting the exact answer by writing $f(z)$ as $u(x,y)+iv(x,y)$ and realizing the Laplacian of f is equal to zero. This leads to a lot of cancellations but I'm still making mistakes in my computations and I can't figure out where. Any help is appreciated. Remember window locations when docked and undocked I find this beyond frustrating.  I have two extra screens on my laptop at work. I take my laptop and go home, with no extra screens connected. I come back, dock the laptop, and the windows need to be rearranged again.  Is there a way to get windows (or a utility) to keep track of the overall screen configuration (#, size, resolution), and remember where windows were placed, so when the screen configuration matches again, it puts applications BACK where they were? Let $f: K^\bullet \to L^\bullet$ be homotopy equivalence. From theory of triangulated categories it follows that $C(f)^\bullet$ is contractible. But how can i produce explicit formula for homotopy of $Id_{C(f)^\bullet}$ and $0_{C(f)^\bullet}$? Fourier Series for $|\cos(x)|$ Virtual Host Setup Redirecting Request to Local IP address What Scoping Class Will  Use? In reading through the release notes I was excited to discover the introduction of a new  tag. That should help lower the barriers to entry! However, the release notes do not specify what the name of the scoping class should be. And since , we're left guessing.  To be explicit about what I'm trying to understand, take  for example:  &lt;apex:page showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0"&gt;     &lt;html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en"&gt;         &lt;head&gt;             ...             &lt;apex:stylesheet value="{!URLFOR($Resource.REPLACE_WITH_NAME_OF_SLDS_STATIC_RESOURCE, 'assets/styles/salesforce-lightning-design-system-vf.min.css')}" /&gt;         &lt;/head&gt;         &lt;body&gt;              &lt;!-- REQUIRED SLDS WRAPPER --&gt;             &lt;div class="REPLACE_WITH_NAME_OF_CUSTOM_SCOPING_CLASS"&gt;             ...         &lt;/body&gt;     &lt;/html&gt; &lt;/apex:page&gt;   If I replace the &lt;apex:stylesheet&gt; with &lt;apex:slds&gt;, what should I specify for REPLACE_WITH_NAME_OF_CUSTOM_SCOPING_CLASS? How to push a copy of an object into array in PHP Why is it differential equations exist on an interval instead of a domain? I understand a domain is the set of input elements a function is defined for (and can have breaks in it e.g. union of 2 sets) and a interval is a continuous range of real numbers. Why do we speak of the solution to a differential equation over an interval instead of an domain? If the solution to an ODE is just a function, and we normally speak of functions as having a domain, then why wouldn't we use domain? How to reverse the pagination numbers of an archive? I have archive pages that each contain titles and excerpts from 10 blog entries. Both entries and archive pages are in reverse chronological order:   when a new blog entry is written its title and excerpt go to the top of the front page; when you are on one page and you click through to "Next page", you get the titles and excerpts for the 10 previous blog entries.   This is pretty standard for blogs.  But the archive pages are numbered by default in the same order. Thus Page 1 contains excerpts from the most recent 10 entries, Page 2 contains excerpts from the next 10 most recent, etc.  To be clear: at the moment, "Next page" refers to the page with the next higher number. Thus the front page, which contains excerpts from the most recent entry and the nine next most recent entries, is labelled Page 1, and the 10 entries posted before those 10 entries are on Page 2.  I need the page-numbering the other way round, namely in direct chronological order, so that for example if there are 97 entries then   entries 28-37 would be excerpted on Page 4, and the PREVIOUS page from there, containing excerpts from entries 18-27, would be called page 3.   How can I achieve this, whether by amending functions.php in the child theme (preferably), by writing a "Snippet" (next most preferred), or by amending archive.php in the Astra parent theme directly (least preferred, because of possible update problems)?  Edit  The following isn't a solution but it may be part of one. This re-numbers pages into direct chronological order, but unfortunately it also reverses the order in which they are shown (from reverse chronological to direct chronological). So it causes the front archive paget to contain excerpts from the earliest posts rather than the latest ones!  &lt;?php  add_filter('pre_get_posts', 'posts_by_forward_date');  function posts_by_forward_date($query) {   if(is_archive() || is_home()) {     $query-&gt;set('order', 'ASC');   } } ?&gt; How do I open PDF in Adobe Reader DC without locking the file from being updated by pdflatex? I don't know if this is possible on Adobe Reader DC on Windows, but asking in case someone has managed to do it.   When I am working on a large document in LaTeX (I use TexStudio) I sometimes like to keep a second copy of my PDF on a second screen so that I can easily refer to what I wrote before, while on my main screen I would have TexStudio with its preview window, which is typically automatically in sync with my current editing location.  On Ubuntu (which uses evince as its default PDF viewer) I used to do it quite nicely. It also seems to watch the PDF file for updates, and keeps in sync of any new versions of the PDF file and reloads it (staying on the same page) when I re-run pdflatex from TexStudio.  At the moment I am working on a Windows machine, and I am trying to recreate the same workflow. I would really like to open a second viewer on my second screen so that I can navigate easily to previous chapters without losing my current position in TexStudio's preview window (which will anyway go back to the current editing location when I run pdflatex).  The only problem however is that when I open the PDF in Adobe Reader DC to put it on the second screen and then I try to recompile the PDF I get the error "I can't write to file". I presume that for some stupid reason Adobe Reader DC maintains some write lock on the file, probably keeping it open while the PDF is visible on screen.  Is there a way to disable this stupid file-locking behaviour from Adobe Reader DC?  UPDATE  After some valuable comments, a workaround is possible using a different viewer. One could either use  or  (the default PDF viewer on Ubuntu, but also available for Windows). They are not so feature rich, and maybe do not look so nice, but in this case do the job.  A similar question was posted  for reference. How are shorter power-plays counted in power play percentage? Binary classification with strongly unbalanced classes The energy of a moving object is $E = mv^2\;.$ That is it increases with velocity squared.  I walk at say 3 miles per hour, or lets round that down to 1 meter per second for a slow walk. I weigh less than $100~\mathrm{kg}\;,$ but lets just round that up to $100~\mathrm{ kg}$ for convenience (it is just after Christmas).  So when I walk along the pavement, I have $100~\mathrm{kg\; m^2 s^{-2}}$, 100 joules of kinetic energy.  Now I get on a passenger jet, which is cruising at around 500 knots, call that 250 meters per second.  In my seat I have $100\times 250^2 = 6250000$ joules of kinetic energy. But when I walk down the aisle I have $100\times 251^2 = 6300100$ joules of kinetic energy. The difference between these is: 50100 joules.  It feels the same to me, walking down the pavement as walking down the aisle of the plane. I didn't have to make some huge effort to get up to speed on the plane, yet I needed 500 times the energy to do it.  How is this possible, and where did the energy come from? show that if $a | c$ and $b | c$, then $ab | c$ when $a$ is coprime to $b$. Given two numbers $a$ and $b$, where $a$ is co-prime to $b$,     Show that for any number $c$, if $a|c$ and $b | c$ then $ab| c$. Is the reverse also true? In other words, if $ab |c$ and $a$ is co-prime to $b$, then do we have $a | c$ as well as $b|c$? Google Chrome PPA upgrade invalid signature