I am trying to implement data structure Linked List (Singly) however by adding elements returns NULLPOINTEREXCEPTION.  import java.util.NoSuchElementException;  public class Linkedlist&lt;ANYTYPE&gt;{  private Node head;  Linkedlist(){     head = null; }  public void add(ANYTYPE data){     head.next = new Node&lt;&gt;(data, head); }  public void traverse(){     if(head == null) throw new NoSuchElementException("List may be empty");      Node temp = head;      while(temp != null){         System.out.println(temp.data+" ");         temp = temp.next;     } }  public static void main(String[] args) {      Linkedlist&lt;String&gt; l=new Linkedlist&lt;String&gt;();     l.add("one");     l.add("two");     l.traverse(); }   private class Node&lt;ANYTYPE&gt;{      private ANYTYPE data;     private Node next;      Node(ANYTYPE data, Node next){         this.data = data;         this.next = next;     } }  }
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?
What are some examples of awkward sounding but grammatically correct sentences? What are some examples of awkward sounding but grammatically correct sentences? Are C++ Templates just Macros in disguise? Loading a package conditionally I am using a linux server which has 128GB of memory and 24 cores. I use top to see how much it is used. Its output is pasted at the end of the post. Here are two questions:  (1) I see that each of the running processes occupies a very small percentage of memory (%MEM no more than 0.2%, and most just 0.0%), but how the total memory is almost used as in the fourth line of output ("Mem:  130766620k total, 130161072k used,   605548k free,   919300k buffers")? The sum of used percentage of memory over all processes seems unlikely to achieve almost 100%, doesn't it?  (2) how to understand the load average on the first line ("load average: 14.04, 14.02, 14.00")?   Thanks and regards!  Edit:  Thanks!  I also really like to hear some rough numbers based on used percentage of memory to determine if a server is heavily loaded, since I once became the one who cramed the server without understanding the current load.  Is swap regarded as almost the same as memory? For example, when memory and swap are almost of same size, if the memory is almost running out but the swap is still largely free, may I just view it as if the used percentage of memory + swap is still not high and run other new processes?  How would you consider together CPU or memory (or memory + swap) usage? Do you become worried if either of them reaches too high or both?  Output of top：  $ top    top - 12:45:33 up 19 days, 23:11, 18 users,  load average: 14.04, 14.02, 14.00 Tasks: 484 total,  12 running, 472 sleeping,   0 stopped,   0 zombie Cpu(s): 36.7%us, 19.7%sy,  0.0%ni, 43.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st Mem:  130766620k total, 130161072k used,   605548k free,   919300k buffers Swap: 63111312k total,   500556k used, 62610756k free, 124437752k cached    PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND  6529 sanchez   18  -2 1075m 219m  13m S  100  0.2  13760:23 MATLAB 13210 timothy   18  -2 48336  37m 1216 R  100  0.0   3:56.75 absurdity 13888 timothy   18  -2 48336  37m 1204 R  100  0.0   2:04.89 absurdity 14542 timothy   18  -2 48336  37m 1196 R  100  0.0   1:08.34 absurdity 14544 timothy   18  -2  2888 2076  400 R  100  0.0   1:06.14 gatherData  6183 sanchez   18  -2 1133m 195m  13m S  100  0.2  13676:04 MATLAB  6795 sanchez   18  -2 1079m 210m  13m S  100  0.2  13734:26 MATLAB 10178 timothy   18  -2 48336  37m 1204 R  100  0.0  11:33.93 absurdity  12438 timothy   18  -2 48336  37m 1216 R  100  0.0   5:38.17 absurdity 13661 timothy   18  -2 48336  37m 1216 R  100  0.0   2:44.13 absurdity 14098 timothy   18  -2 48336  37m 1204 R  100  0.0   1:58.31 absurdity 14335 timothy   18  -2 48336  37m 1196 R  100  0.0   1:08.93 absurdity 14765 timothy   18  -2 48336  37m 1196 R   99  0.0   0:32.57 absurdity 13445 timothy   18  -2 48336  37m 1216 R   99  0.0   3:01.37 absurdity 28990 root      20   0     0    0    0 S    2  0.0  65:50.21 pdflush 12141 tim       18  -2 19380 1660 1024 R    1  0.0   0:04.04 top  1240 root      15  -5     0    0    0 S    0  0.0  16:07.11 kjournald  9019 root      20   0  296m 4460 2616 S    0  0.0  82:19.51 kdm_greet     1 root      20   0  4028  728  592 S    0  0.0   0:03.11 init     2 root      15  -5     0    0    0 S    0  0.0   0:00.00 kthreadd     3 root      RT  -5     0    0    0 S    0  0.0   0:01.01 migration/0     4 root      15  -5     0    0    0 S    0  0.0   0:08.13 ksoftirqd/0     5 root      RT  -5     0    0    0 S    0  0.0   0:00.00 watchdog/0     6 root      RT  -5     0    0    0 S    0  0.0  17:27.31 migration/1     7 root      15  -5     0    0    0 S    0  0.0   0:01.21 ksoftirqd/1     8 root      RT  -5     0    0    0 S    0  0.0   0:00.00 watchdog/1     9 root      RT  -5     0    0    0 S    0  0.0  10:02.56 migration/2    10 root      15  -5     0    0    0 S    0  0.0   0:00.34 ksoftirqd/2    11 root      RT  -5     0    0    0 S    0  0.0   0:00.00 watchdog/2    12 root      RT  -5     0    0    0 S    0  0.0   4:29.53 migration/3    13 root      15  -5     0    0    0 S    0  0.0   0:00.34 ksoftirqd/3 How do I start Chrome using a specified "user profile"? say by has the meaning of      6. indicating the period in which something happens: ‘this animal always hunts by night’   Then do we need to say, ‘Why does the sky glitter by night?’ And can’t we say, ‘Why does the sky glitter at night?’?   If we can use both, what’s the difference between the two? How can I find the right lens cap for my lens? I own a Nikon D3000 Camera with the AF-S 18-55mm VR Kit Lens. Last week I lost the lens cap and now I want to buy a new one.  But when I went to , I got confused with the different ranges of lens names —  LC-62, LC-78, etc.  My concern is what if I order one lens cap and it won't fit correctly on my lens?  If you guys have an D3000, can you please let me know how to find the correct lens cap names? What is the difference between Θ(n) and O(n)? Sometimes I see Θ(n) with the strange Θ symbol with something in the middle of it, and sometimes just O(n). Is it just laziness of typing because nobody knows how to type this symbol, or does it mean something different? I am using \if condition in a custom command in my LaTeX document. I would like to know where I can find some good explanation about \if command. I followed a  but it's just an example; there are not any explanation. Whats this white stuff on my board? Define additional math operators to be typeset in roman RemoveDuplicates gives 1004 error Diamond is not shown for mod name under wiki posts If a diamond mod is an author of a wiki post then the diamond is not displayed besides the mod name. E.g. :        Even when the name refers to the user profile page (in case of more then one author) like in :        Is it intentional or a bug? Java FileInputStream ObjectInputStream reaches end of file EOF When is using the past perfect tense not necessary? Is it more natural to speak in simple past or past perfect when explaining past events to a friend? It seems like Americans use more simple past in everyday life than past perfect. I found this example online:     I had almost completed my essay when my computer suddenly crashed and I noticed that I had forgotten to save the document.   Is it wrong to say the following instead?     I was almost done with my essay when my computer suddenly crashed and I noticed that I forgot to save the document.   Maybe it's just my friends, but I rarely hear them speak in past perfect, so I'm really torn about using past perfect when it isn't necessary. How to write ≙ in latex Show that a matrix $A$ is singular if and only if $0$ is an eigenvalue. I can't find the missing link between singularity and zero eigenvalues as is stated in the following proposition:  A matrix $A$ is singular if and only if $0$ is an eigenvalue.  Could anyone shed some light? I have a loop that is doing some error checking in my PHP code. Originally it looked something like this...  foreach($results as $result) {     if (!$condition) {         $halt = true;         ErrorHandler::addErrorToStack('Unexpected result.');     }      doSomething();  }  if (!$halt) {     // do what I want cos I know there was no error }   This works all well and good, but it is still looping through despite after one error it needn't. Is there a way to escape the loop? How to get world-space matrix of any pose bone? Is there a command for getting world-space matrix of pose bones, same as obj.matrix_world for objects? I found pose_bone.matrix, but it gives weird result for me. Can you raise a number to an irrational exponent?