Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You say this is the line of code causing the exception:</p> <pre><code>while(temp.object.style.compareTo(element.style) &lt;= 0) </code></pre> <p>You probably should set a debugger breakpoint on that line and use a debugger to determine which of the values is null. But it's hard for me to explain here full instructions on how to setup and use a debugger (that doesn't mean you shouldn't learn! You should. There are lots of tutorials. Google it.) So instead of writing a tutorial on debuggers, I'll just post code that will tell you which variable is null:</p> <pre><code>if (temp == null) { System.out.println("temp is null"); } else if (temp.object == null) { System.out.println("temp.object is null"); } else if (temp.object.style == null) { System.out.println("temp.object.style is null"); } if (element == null) { System.out.println("element is null"); } else if (element.style == null) { System.out.println("element.style is null"); } while(temp.object.style.compareTo(element.style) &lt;= 0) //This is where the nullPointerException occurs { if(temp.hasNext()) temp = temp.next; if (temp == null) { System.out.println("loop: temp is null"); } else if (temp.object == null) { System.out.println("loop: temp.object is null"); } else if (temp.object.style == null) { System.out.println("loop: temp.object.style is null"); } if (element == null) { System.out.println("loop: element is null"); } else if (element.style == null) { System.out.println("loop: element.style is null"); } } </code></pre> <p>If you use the above code statements to replace these three lines of your code:</p> <pre><code> while(temp.object.style.compareTo(element.style) &lt;= 0) //This is where the nullPointerException occurs if(temp.hasNext()) temp = temp.next; </code></pre> <p>you will know which variable is null based on which statement is printed. Hopefully you can take it from there. (The usual way to fix a NullPointerException is to take the steps necessary to ensure the offending null variable actually has a valid, non-null value by the time the program reaches the line of the NullPointerException).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload