Here is the code i have written, it works fine until i get to the loop, it crashes showing NullPointerException  Looks like i am missing something very basic here.. but when i run the algorithm on pen &amp; paper i don't see any problem at all.  What am i doing wrong please help !  package lesson.datastructure;  public class MergeSort {      public static Node getSortedNode1(){         Node n1=new Node();         n1.value=2;         Node n2=new Node();         n2.value=76;         Node n3=new Node();         n3.value=98;         n1.next=n2;         n2.next=n3;         n3.next=null;         return n1;     }     public static Node getSortedNode2(){         Node n1=new Node();         n1.value=23;         Node n2=new Node();         n2.value=65;         Node n3=new Node();         n3.value=87;         n1.next=n2;         n2.next=n3;         n3.next=null;         return n1;     }     public static void printNode(Node head,String name){          System.out.println(name);         while(head!=null){             System.out.print(head.value+"-&gt;");             head=head.next;         }         System.out.println("\n\n");     }      /* Main method ignore all other methods */     public static void main(String[] args){          Node head1,head2;         head1=getSortedNode1();         head2=getSortedNode2();          printNode(head1, "List 1");         printNode(head2, "List 2");          Node sortedMergedList=null;          if(head1.value&lt;head2.value){             Node nextNode=head1.next;             Node isolatedNode=null;             isolatedNode=head1;             isolatedNode.next=sortedMergedList;             sortedMergedList=isolatedNode;             head1=nextNode;         }         else         {             Node nextNode=head2.next;             Node isolatedNode=null;             isolatedNode=head2;             isolatedNode.next=sortedMergedList;             sortedMergedList=isolatedNode;             head2=nextNode;         }           while(head1!=null || head2!=null){        //Null pointer here while accessing head1 or head2             if(head1.value&lt;head2.value){                 Node nextNode=head1.next;                 Node isolatedNode=null;                 isolatedNode=head1;                 isolatedNode.next=sortedMergedList;                 sortedMergedList=isolatedNode;                 head1=nextNode;             }             else             {                 Node nextNode=head2.next;                 Node isolatedNode=null;                 isolatedNode=head2;                 isolatedNode.next=sortedMergedList;                 sortedMergedList=isolatedNode;                 head2=nextNode;             }          }             printNode(sortedMergedList, "merged sorted list");      }       }
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?
Displaying two XML listings side by side. I have two XML outputs from a program that I would like to include in a LaTeX document. I would like them to appear side-by-side each in its own box. So that a reader can compare the two outputs while reading the document. Can't seem to find a way to do this, without making images for each output and adding both as images/graphics. Could there be a better option? A cashier wants to work five days a week, but he wants to have at least one of the Saturday and Sunday off.  In how many ways can he choose the days he will work?  So, in this case, what should I count first?  How do I start?  I know how to solve this if the cashier doesn't want a weekend off, but what do I do if the cashier do?  Thanks! Understanding integrals double meaning I would like to understand why the integrals represent 2 things:   If we only do an integral without bounds on $f(x)$, the integral gives us the function $F(x)$ that, when differentiated, gives us the original function $f(x)$. If we do an integral with bounds $[a,b]$ on $f(x)$, it gives us the area under $f(x)$ by evaluating the difference $F(b) - F(a)$.   Why does $F(x)$ represent the area under $f(x)$ as well as the first point? Measuring accuracy of latitude and longitude? Why are bias nodes used in neural networks?  How many you should use?  In which layers you should use them: all hidden layers and the output layer? Drag and drop not working inside Nautilus on Ubuntu 17.10 I'm having a strange problem on Ubuntu 17.10: when I try to drag and drop something inside Nautilus it simply doesn't work, it doesn't even select the item, it seems like it's ignoring the action... Also, I cannot select things inside nautilus by drawing rectangles with the mouse.  All of these actions work only on the Desktop. Here is a demo:    I'm using the Xorg session with nVidia proprietary drivers. I also noticed that Nautilus seems to hang when I try to copy, paste or cut a file...  EDIT 1: I solved the problem for the slow copy/paste by disabling the clipboard sync plugin of KDEConnect. I also discovered that if I open Nautilus as root, I can drag and drop or select whatever I want... Cleaning up factor levels (collapsing multiple levels/labels) Consider the following minimal example:  \documentclass{article}  \setlength{\parindent}{0mm}  \usepackage{paralist} \usepackage{tabto}  \begin{document}  \NumTabs{3} \begin{inparaenum} \item text \tab\item text \tab\item text \tab\item text \tab\item text \tab\item text    \end{inparaenum}  \end{document}   Which results in:    It does exactly what I want, but I was wondering whether it was possible to create an environment, say tabbedEnum so that we can eliminate the use of the \tab, in particular, that the first case doesn't need a tab but all others do. Something of the form:   \begin{tabbedEnum}[3] \item text \item text \item text \item text \item text \item text \end{tabbedEnum} Why is Python running my module when I import it, and how do I stop it? Unable to format internal drive as APFS on 2018 MacBook Pro How can I make a copy of a material? Suppose the mean noon-time temperature for September days in San Diego is 24∘ and the standard deviation is 4.9. (Temperature in this problem is measured in degrees celsius)  On September 26, 1963, the all-time record of noon-time temperature in San Diego of 44∘ was hit. Assume the temperature distribution is symmetric around the mean, what is the Chebyshev bound for the probability of breaking (or tieing) this record?  I am having a hard time understanding this. Could someone explain to me how to do this? My tea bags are expired, can I still use them? This box of tea has an expiration date which has passed but I would like to know if I can still use it. What do you think? Without recasting and in lieu of unsightly suspensive hyphenation, could these work? The en dash (which means "to") is used between the figures, and the hyphens are used in the compound modifier. To me, the examples below are concise and clear.  Do you agree that the examples below are 100% punctuated correctly--yes or no?  45–50-year-old men  10–20-mile radius  $45–$55-million-per-year industry  $100,000–$150,000-a-year savings  10–15-degree temperature difference  $2–$5-per-day service fees  45–75-cent-a-week raises  55–65-mph speed zone  15–20-ounce steaks  20%–40%-a-year tax increases Properties of $x_k=\frac{a_{k+1}-a_{k}}{a_{k+1}}$ where $\{a_n\}$ is unbounded, strictly increasing sequence of positive reals Let $\{a_n\}$ be an unbounded, strictly increasing sequence of positive real numbers and let $x_k=\frac{a_{k+1}-a_{k}}{a_{k+1}}$. Which of the following statements is/are correct? (CSIR NET December 2014)         For all $n\geq m, \sum\limits^{n}_{k=m}x_k&gt;1-\bf{\frac{a_m}{a_n}}$   There exist $n\geq m, \sum\limits^{n}_{k=m}x_k&gt;\frac{1}{2}$      My attempt:  Analysing question in light of $a_k=k\implies x_k=\frac{k+1-k}{k+1}=\frac1{k+1}$, I feel both are correct, I doubt if  I can generalise the result in light of this one example.   Any way to prove that this true for general case?    Note: Please do not confuse  with my question. The first two options are different, I've marked the difference in bold. Split $n$ into nontrivial factors via a nontrivial square-root of $1\!\pmod{\!n}$ Coming from an understanding of Fermat's primality test, I'm looking for a clear explanation of the Miller-Rabin primality test.  Specifically: I understand that for some reason, having non-trivial square roots of 1 mod p means that p is definitely composite; and I gather that you can find these non-trivial square roots by squaring x, but I don't really understand what these reasons are. Specific examples of non-trivial roots of a composite number would be helpful.  Cheers! The Ubuntu installer does not allow me to install on NTFS partitions, but certain circumstances requires me to do so. Is it possible? Question of an isomorphism of $\epsilon_ 0$ and a subset of the rationals. I don't know if this question is appropriated for this site. Anyway, I'm searching for an isomorphism of order $f:K \longrightarrow \epsilon_o $, such that $(K, \leq)$ is a subset(proper or not) of $(\mathbb{Q}, \leq)$ and $\epsilon_o = \sup\{\omega, \omega^{\omega}, \omega^{\omega^{\omega}}, ... \}$. Actually,  I'm not finding neither an isomorphism between $K$ and $\omega^{\omega}$.  Thanks in advanced. Is WD-40 really bad to apply on bikes? I was told so but still see people doing that.   Also I saw WD-40 launching their new products of bike lubricant and degreaser. Did anybody try those? How can I replace a string in a file(s)?