I'm a beginner in programming and I need to write some kind of own LinkedList, but only with add(E element) method and with Iterator's hasNext() and next(). Here is my code:    public class LinkedArray&lt;E&gt; implements Iterator&lt;E&gt; {          private int size = 0;          private int current = 0;          private Node&lt;E&gt; first;          private Node&lt;E&gt; last;          private Objects[] objects = new Objects[10];          public void add(E value) {             Node&lt;E&gt; element = new Node&lt;E&gt;(last, value, null);             if (last != null) {                 element.next = element;             } else {                 first = element;             }             last = element;             size++;         }          @Override         public boolean hasNext() {             boolean result = false;             try {                 if (objects[current + 1] != null) {                     result = true;                 }             } catch (ArrayIndexOutOfBoundsException e) {                 result = false;             }             return result;         }          @Override         public E next() {             E result;             try {                 current++;                 result = (get(current - 1));             } catch (ArrayIndexOutOfBoundsException a) {                 throw new NoSuchElementException("No more elements in list.");             }             return result;         }     public E get(int position) throws NullPointerException {         Object result;     if (this.objects[position] != null) {         result = this.objects[position];     } else {         throw new NullPointerException("Position is empty.");     }     return (E) result; }           private class Node&lt;E&gt; {              private E element;              private Node&lt;E&gt; next;              private Node&lt;E&gt; prev;              Node(Node&lt;E&gt; prev, E element, Node&lt;E&gt; next) {                 this.element = element;                 this.next = next;                 this.prev = prev;             }         }     }   But when I started to test add(E value)...  @Test     public void test() {         LinkedArray&lt;String&gt; arr = new LinkedArray&lt;&gt;();         String string = "Test";          arr.add(string);         String result = arr.next();          assertThat(result, is("Test"));     }   ...I only get an error. What the problem is, why am I getting it wrong?
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?
The most efficient way to implement an integer based power function pow(int, int) I am using gedit text editor with embedded terminal in ubuntu 12.04. I'm trying to search for some text using grep. I want to search for this line of code   'type' =&gt; 'select'   I tried:  grep -r '\'type\' =&gt; \'select\''  But grep didn't return any results.  So can someone kindly tell me how to search for the code above? Create a page for useful links? Trying to remap my left SUPER key (also called WINDOWS key) to left or right CONTROL key, with xkg How can I install a Canon printer or scanner driver? I tried to install the MP190 drivers, but appeared a message show me that requires to have libcupsys2. I understand that libcup2 is an update of libcupsys2.   How do I solve this? Are there proprietary drivers for my Canon printer or scanner? I use dd in its simplest form to clone a hard drive:  dd if=INPUT of=OUTPUT   However, I read in the manpage that dd knows a blocksize parameter. Is there an optimal value for the blocksize parameter that will speed up the cloning procedure? How does Router know where to forward packet Why “which” returns none on some commands I can run? I used which to tell the location of a runnable file. For example, which pwd returns /bin/pwd. However, I found which alias or which compgen etc returns nothing.   What are commands like alias? Aren't they executable files on my Linux? I am using bash 4.3 on Ubuntu. Editing photo dimensions in large batches If I had the time, I would go through each and every photo to make sure that the dimensions and quality are pixel perfect. However, I'm in a time crunch, and need to make the couple hundred photos that are 4320 x 3240 into 950x630.   now I could- 1. Upload them into WordPress, uses native image reducing components and J query go from there. 2. Go through each and every photo, reduce file size, and proportion and bring it to Yahoo's PNG processing script.  However, maybe I'm missing a choice or alternative workflow that would allow for processing all of these photos in a clear manner without losing quality or perspectives. Any workflow suggestions? How to modify an invalid '/etc/sudoers' file? SQLiteException while inserting values in the database in Android Calculate expected values using logistic regression coefficients $a_1 a_1', a_2 a_2', ..., a_n a_n'$ is not a reduced modulo system $\mod p$. If $a_1, a_2, ..., a_n$ is a reduced residue system $\mod p$ and $a_1', a_2', ..., a_n'$ is another reduced residue system $\mod p$ then $a_1 a_1', a_2 a_2', ..., a_n a_n'$  is not a reduced modulo system $\mod p$.  Not able to show a counter to it. Help Needed. What are some important applications of the Erdős-Szekeres Theorem? What causes close votes to be annotated with "(deleted)"? In the "Votes Cast" section of my profile, my vote to close  is annotated with "(deleted)":    However, the close vote does not appear to have been deleted: it successfully closed the question:    Why was this vote marked as "(deleted)"?    If the vote was deleted my some internal process after the question was closed and the closers were recorded, I call that a . Regardless of what happens internally, it's irrelevant to users if close votes are deleted after they have taken effect. El Captain update download doesn't continue after restarting the Mac I started to download the El Capitan upgrade, but then I shut down my computer. The day after I wanted to continue the download but in App Store it shows "Waiting..." and doesn't do anything. Also when I go to the updates section, it shows the button "Download" but it's inactive. Maybe someone can help me? I tried to find the download file in some directory to delete it and start over but I couldn't find it. My sketch exports seem to be pixelated even when am exporting it to 1x How do I extract a single chunk of bytes from within a file? How to programmatically login/authenticate a user? Install a .NET windows service without InstallUtil.exe