sM is an instance of the class, When running the method staffCanWork it is supposed to return a List of staff objects that can work on the given date and time, however when running the method it null pointer errors.  Testing the method within static void main;    Date date = Date.valueOf(LocalDate.now());         List&lt;Staff&gt; staff = sM.staffCanWork(date, Time.valueOf(LocalTime.now()));         for(int i = 0; i &lt; staff.size(); i++){             System.out.println(staff.get(i).getId());         }   Method getStaff() using hibernate populates the List with staff objects using hibernate.       public List&lt;Staff&gt; getStaff(){         List staff =null;         Session session = factory.openSession();         Transaction tx = null;         try {             tx = session.beginTransaction();             TypedQuery query = session.getNamedQuery("getStaff");;             staff = query.getResultList();         }catch (HibernateException e){             e.printStackTrace();         }return staff;     }    staffCanWork method, Checks through the list to see if staff can work the given date and time.      public List&lt;Staff&gt; staffCanWork(Date date, Time time){         List&lt;Staff&gt; staff = getStaff();         List&lt;Staff&gt; staff1 = null;         for(int i = 0; i &lt; staff.size(); i++){             if(staff.get(i).getDoctor() == null){                 if(staff.get(i).getNurse().canWork(date, time)) staff1.add(staff.get(i));             }             else {                 if(staff.get(i).getDoctor().canWork(date, time)) staff1.add(staff.get(i));             }         }         System.out.println(staff1.get(0).getId() + "test");         return staff1;     }   Method CanWork  public boolean canWork(Date date, Time time){         Boolean canWork =false;         Boolean aM = false;          if(time.getTime() &lt; 12){ aM = true;}         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E");         simpleDateFormat.format(date);         if(aM = true) {             switch (simpleDateFormat.format(date)) {                 case "Mon": if (getMondayAM() == true) canWork = true;                     break;                 case "Tue" :if (getTuesdayAM() == true) canWork = true;                     break;                 case "Wed" :if (getWednesdayAM() == true) canWork = true;                     break;                 case "Thu" :if (getThursdayAM() == true) canWork = true;                     break;                 case "Fri" :if (getFridayAM() == true) canWork = true;                     break;                 case "Sat" :if (getSaturdayAM() == true) canWork = true;                     break;                 case "Sun" :if (getSundayAM() == true) canWork = true;                 default: return false;             }         }         switch (simpleDateFormat.format(date)) {             case "Mon": if (getMondayPM() == true) canWork = true;                 break;             case "Tue" :if (getTuesdayPM() == true) canWork = true;                 break;             case "Wed" :if (getWednesdayPM() == true) canWork = true;                 break;             case "Thu" :if (getThursdayPM() == true) canWork = true;                 break;             case "Fri" :if (getFridayPM() == true) canWork = true;                 break;             case "Sat" :if (getSaturdayPM() == true) canWork = true;                 break;             case "Sun" :if (getSundayPM() == true) canWork = true;             default: return false;         }         return canWork;     }
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?
How to find out the terminal command of an application? the problem of using "~\\" and blank line Recently,I found the code that cotains the"~\\" and blank line always shows the warning imformation "Underfull \hbox (badness 10000) in paragraph at lines"  \documentclass{ctexart} \usepackage{color} \usepackage{amsmath} \usepackage{amssymb} \usepackage{graphicx} \usepackage{epstopdf} \hfuzz=\maxdimen   $(A \pm  B)^{-1} \neq A^{-1} \pm B^{-1}$,$(A \pm  B)^* \neq A^* \pm B^*$~\\  $|(A^*)^*|=|A|^{n^2-2 n+1}$~\\  \end {document}   I add the code:  \tolerance=10000 \hbadness=10000 \begin{document}   However,fail to solve it! Correct interpretation of a "double-negative" in American Pop Culture (i.e. "I ain't afraid of no ghost!") Problems installing xpatch I need to install the xpatch package to make changes to my biblatex setup. The readme file in the install package simply says to run “latex xpatch.ins.” I've moved the xpatch folder (including xpatch.ins and xpatch.dtx files) to the /usr/local/texlive/2011/../texmf-local/ folder. When I run the command above, I get the output Generating file(s) ./xpatch.sty  ! Cannot find file xpatch.dtx. \readsource ...ot find file \uptospace #1 \qStop }                                                   \else \processedLines \z@ ... l.34 ...xpatch.sty} {\from{xpatch.dtx} {package}}}   I've checked, and the .dtx file is in the folder. Any ideas what the problem is? Would spending one more year as an undergraduate adversely affect my chances of getting into a graduate program?   I wasn't really thinking about economics PhD until recently so my GPA is not too impressive and I lack in math courses so I've decided to spend one more year to boost my GPA taking upper level courses and get a math minor.  However, could the very fact of spending one more year to finish college be a disadvantage of getting into a graduate program? Auto-run scripts security options What's the regular expression that matches a square bracket? Adding related resources or hyperlinks in edits So, I've been rejecting the addition of resources/hyperlinks to posts simply because I had no idea that this was an acceptable practice.  Today, I was browsing through the edits page and saw:     Some common reasons to edit are:         to fix grammatical or spelling mistakes   to clarify the meaning of a post without changing it   to correct minor mistakes or add addendums / updates as the post ages   to add related resources or hyperlinks      Why is this an acceptable practice?  I can see adding links to official documentation, but the quality of outside resources is (potentially) subjective.  I see the merit in adding resources, but it seems to me that these additional resources should be placed in comments, not inserted into the post via an edit.  Anyone have thoughts on this? Mavericks unusually high RAM usage I thought Mavericks was suppose to utilize RAM memory better, thus run smoother.  Running ML on Mac mini 2012, with 16GB RAM...always running smoothly even with over a dozen apps running.  Now, after installing Mavericks, my Mac is SLOW, eating up RAM like crazy! Looking over usage, of the 16GB of installed memory...on average it uses 10-14 GB RAM when barely running a few apps!!!   There is this kernel_task that is always running with over 1GB of RAM and most apps are not taking that much RAM, so what is using up all my RAM?! File cache? It shows very high in that new description, with about 1/3 of my total RAM AND gate made out of transistors letting current pass despite only one input high I recently built a gate with transistors, however my meter reads 1.6 volts when only input B is high, and 2.3 while both are high. How can I fix this? (I used 3 volts instead of 6 and 2k instead of 10k) Why doesn't "its" have an apostrophe? I know that its is the possessive and it's is the contraction, and know when to use them.  But why doesn't the possessive have an apostrophe?   "The bear's eating a fish." [contraction] "The bear's coat is brown." [possessive] "It's eating a fish." [contraction] "Its coat is brown." [possessive] "One's eating a fish." [contraction] "One's coat is brown." [possessive]    lists the etymology as "From  +‎ ", and  says that this is actually the original form:     Originally written it's, and still deliberately spelled thus by some writers until early 1800s.   So what happened to the apostrophe?  When did people stop using it, and why did they?  It seems that it's as the possessive is more natural, as most people do this until they're taught that it is wrong (or even after).  Update: Online Etymology Dictionary has been updated to include two potential explanations:     The apostrophe came to be omitted, perhaps because it's already was established as a contraction of it is, or by general habit of omitting apostrophes in personal pronouns (hers, yours, theirs, etc.).   Can anyone back up either of these arguments?  The possessive one's still has the apostrophe, despite these. Can I change the color of the last selected face? Can I change the color of the last selected face, so that it is the same as the other selected faces?  Here, I've selected the left face then the right face. Note the right face is some sort of checkered or dithered pattern, and just the outline has the nice orange 'selected' color.    Here I've selected the top face, note the right face has now the nice color.    And here I've deselected the top face. Now, both of the remaining selected faces have the nice color. This is the result I'd rather see instead of image 1. What is the sum of non-real roots of the polynomial equation? I am running a fresh install of Linux Mint Nadia (14). I am following the instructions on Vagrant  but have gotten stuck on the . It seems the Vagrant box cannot connect outside and so I can't install anything using either Chef or Puppet.  In the basic Vagrant resolve.conf contains nameserver 10.0.2.3. But with that set I can't ping us.archive.ubuntu.com.  If I change it to 8.8.8.8 then I can ping us.archive.ubuntu.com but it does not stay set, and after a reboot it changes back to 10.0.2.3 - so provisioning fails again.  Ideally I would like for 10.0.2.3 to work on my setup. Failing that I would like a way to permanently change resolv.conf so that I can do provisioning. How to override Drupal.ajax.prototype.beforeSend? I need to add my own little if's and checks in 3 functions inside   misc/ajax.js (   Drupal.ajax.prototype.beforeSend,   Drupal.ajax.prototype.success,   Drupal.ajax.prototype.error )   How can I override them in my module? I can't find a manual and it's not in Examples for Developers. Sorry if it seems a dumb question, but I'm a php developer - I can work with js, but I'm not so fluent with it.   Can I simply write it in my module's js file? If 2 or 3 modules needs to modify them, how to avoid conflicts? How do I reset a sequence in Oracle? In , I can do something like this:  ALTER SEQUENCE serial RESTART WITH 0;   Is there an Oracle equivalent? Is the following layout possible with the subfigure package? Dropping one of the columns when using one-hot encoding Checking if a key exists in a JavaScript object? We have two sequences , $(a_i)_{i=1}^{2n}$ and $(b_i)_{i=1}^{2n}$ such that  $1\leq a_i, b_i\leq n$ for every $i$.  Show that there are two sets of indexes $I, J \subseteq \left \{ 1,2, ... 2n \right \}$ such what $\sum_{i\in I}a_i=\sum_{j\in J}b_j$.  Well, the question didn't say anything about those sets being empty but I believe that's not what they meant. I don't know that to do with questions like these. There are obviously much more subsets that possible sums ($2^{2n}-1$ compared to $2n^2$) but it doesn't really help.  I'd be glad to hear ideas, hints or solutions.