I'm a newbie to java. I have written the following program :   import java.util.ArrayList; import java.io.*; import java.util.*;    public class dotcombust{     GameHelper helper=new GameHelper();     ArrayList&lt;Dotcom&gt; dotcomlist;     int nofguess=0;      private void setup(){             Dotcom one =new Dotcom();         dotcomlist.add(one);         Dotcom two= new Dotcom();         dotcomlist.add(two);         Dotcom three= new Dotcom();         dotcomlist.add(three);          for(Dotcom obj : dotcomlist)         {             obj.setname();             ArrayList&lt;String&gt; loc= helper.placeDotCom(3);             obj.setlocation(loc);         }     }      private void startplaying(){             while(!dotcomlist.isEmpty())         {             nofguess++;             String guess=helper.getUserInput("Enter a guess ");              checkuser(guess);         }         finish();     }      private void checkuser(String guess){             String result="miss";         for(Dotcom obj : dotcomlist)         {             result=obj.checkyourself(guess);             if(result.equals("kill"))             {                 System.out.println("You killed " + obj.name);                 dotcomlist.remove(obj);                 break;             }             else if(result.equals("hit"))             {                 break;             }        }         if(result.equals("hit") || result.equals("miss"))        {            System.out.println(result);        }     }      private void finish(){         System.out.println("You took " + nofguess + "guesses. If they are below 10, congrats. Otherwise you suck balls. No offense.");     }      public static void main(String[] args){         dotcombust game;         game=new dotcombust();         game.setup();         game.startplaying();     } }   When i run the program, i'm getting java.lang.NullPointerException at dotcombust.setup() and dotcombust.startplaying() statements. I thought that the classes Dotcom and Gamehelper are not related to the error and hence did not display them here. Please help me to fix the problem. Also, i wanted to know if it was possible to write the classes Dotcom and Gamehelper in different source file but use it in this code? If so how?.
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?
I want to run a script on all files with two specific extensions on a disk with a hierarchy of multiple nested folders.  My script works fine when I choose a folder further down the line with fewer subfolders but I'd like to run it on an entire archive with over a thousand folders.  The AppleScript takes forever to get all the files and then exits without returning anything and without executing the operations after getting the files.  No timeout message, no error message.  And the Finder becomes unresponsive (and remains stuck after the script exits).   set myFolder to choose folder with prompt "Choose a folder:"     tell application "Finder"         try             set eafFiles to (every file in entire contents of myFolder whose name ends with ".eaf") as alias list         on error             try                 set eafFiles to ((every file in entire contents of myFolder whose name ends with ".eaf") as alias) as list             on error                 set eafFiles to {}             end try         end try         try             set pfsxFiles to (every file in entire contents of myFolder whose name ends with ".pfsx") as alias list         on error             try                 set pfsxFiles to ((every file in entire contents of myFolder whose name ends with ".pfsx") as alias) as list             on error                 set pfsxFiles to {}             end try         end try         set myFiles to eafFiles &amp; pfsxFiles     end tell      repeat with CurrentFile in myFiles         set CurrentFile to CurrentFile as string          do shell script "perl /path/to/perl/script.pl " &amp; quoted form of CurrentFile     end repeat Why is a subgroup with the index of 2 normal to the group?  I believe it has something to do with it being half and having nowhere to go. That's kind of a recursive Google Search that should be self-explanatory. It did take me some time to tweak the sentence and trying to find a number which would correspond precisely, the reason why I changed it to "hundreds" instead! :P  If you have used Google long enough you certainly have stumbled on situations similar to this, many times. Whenever it shows less than 10 pages it's quite easy to see it. The point is: the number of results on any page except the last one seems like a terrible estimate.  What's even weirder,  the estimate suddenly becomes much better and almost exactly the same on all pages than it is on the last page - the only page that's always correct.  So, anyone knows why? In thinking about Sturm-Liouville theory a bit I see I have no actual idea what is going on.  The first issue I have is that my book began with the statement that given  $$L[y] = a(x)y'' + b(x)y' + c(x)y = f(x)$$  the problem $L[y] \ = \ f$ can be re-cast in the form $L[y] \ = \ \lambda y$.  Now it could be a typo on their part but I see no justification for the way you can just do that!  More importantly though is the motivation for Sturm-Liouville theory in the first place. The story as I know it is as follows:  Given a linear second order ode   $$F(x,y,y',y'') = L[y] = a(x)y'' + b(x)y' + c(x)y = f(x)$$  it is an exact equation if it is derivable from a differential equation of one order lower, i.e.  $$F(x,y,y',y'') = \frac{d}{dx}g(x,y,y').$$  The equation is exact iff  $$a''(x) - b'(x) + c(x) = 0. $$  If $F$ is not exact it can be made exact on multiplication by a suitable integrating factor $\alpha(x)$.  This equation is exact iff  $$(\alpha(x)a(x))'' - (\alpha(x)b(x))' + \alpha(x)c(x) = 0 $$  If you expand this out you get the Adjoint operator  $$L^*[\alpha(x)] \ = \ (\alpha(x)a(x))'' \ - \ (\alpha(x)b(x))' \ + \ \alpha(x)c(x) \ = 0 $$  If you expand $L^*$ you see that we can satisfy $L \ = \ L^*$ if $a'(x) \ = \ b(x)$ &amp; $a''(x) \ = \ b'(x)$ which then turns $L[y]$ into something of the form  $$L[y] \ = \ \frac{d}{dx}[a(x)y'] \ + \ c(x)y \ = \ f(x).$$  Thus we seek an integratiing factor $\alpha(x)$ so that we can satisfy this &amp; the condition this will hold is that $\alpha(x) \ = \ \frac{1}{a(x)}e^{\int\frac{b(x)}{a(x)}dx}$  Then we're dealing with:  $$\frac{d}{dx}[\alpha(x)a(x)y'] \ + \ \alpha(x)c(x)y \ = \ \alpha(x)f(x)$$  But again, by what my book said they magically re-cast this problem as  $$\frac{d}{dx}[\alpha(x)a(x)y'] \ + \ \alpha(x)c(x)y \ = \ \lambda \alpha(x) y(x)$$  Then calling  $$\frac{d}{dx}[\alpha(x)a(x)y'] \ + \ ( \alpha(x)c(x)y \ - \ \lambda \alpha(x) )y(x) \ = \ 0$$  a Sturm-Liouville problem.  My question is, how can I make sense of everything I wrote above? How can I clean it up &amp; interpret it, like at one stage I thought we were turning our 2nd order ode into something so that it reduces to the derivative of a first order ode so we can easily find first integrals then the next moment we're pulling out eigenvalues &amp; finding full solutions - what's going on? I want to be able to look at $a(x)y'' \ + \ b(x)y' \ + \ c(x)y \ = \ f(x)$ &amp; know how &amp; why we're turning this into a Sturm-Liouville problem in a way that makes sense of exactness &amp; integrating factors, thanks for reading! I've created a script that runs every night on my Linux server that uses mysqldump to back up each of my MySQL databases to .sql files and packages them together as a compressed .tar file.  The next step I want to accomplish is to send that tar file through email to a remote email server for safekeeping.  I've been able to send the raw script in the body an email by piping the backup text file to mailx like so:  $ cat mysqldbbackup.sql | mailx backup@email.com   cat echoes the backup file's text which is piped into the mailx program with the recipient's email address passed as an argument.  While this accomplishes what I need, I think it could be one step better, Is there any way, using shell scripts or otherwise, to send the compressed .tar file to an outgoing email message as an attachment?  This would beat having to deal with very long email messages which contain header data and often have word-wrapping issues etc. If $f_k \to f$ a.e. and the $L^p$ norms converge, then $f_k \to f$ in $L^p$ Let $1\leq p &lt; \infty$. Suppose that    $\{f_k\} \subset L^p$ (the domain here does not necessarily have to be finite),  $f_k \to f$ almost everywhere, and  $\|f_k\|_{L^p} \to \|f\|_{L^p}$.    Why is it the case that $$\|f_k - f\|_{L^p} \to 0?$$   A statement in the other direction (i.e. $\|f_k - f\|_{L^p} \to 0 \Rightarrow \|f_k\|_{L^p} \to \|f\|_{L^p}$ ) follows pretty easily and is the one that I've seen most of the time. I'm not how to show the result above though. This question and answer is a response to a request from Joseph Wright.   Why shouldn't I use getnonfreefonts to install additional fonts? Why shouldn't I use updmap when installing or removing fonts?     Background  There are a number of questions on the site concerning problems caused by people installing additional fonts and using updmap to update the 'map' files on which TeX depends.  One common cause of these problems is the use of getnonfreefonts.  Other causes are the use of other font installation scripts or executing updmap directly. Delete all but the most recent X files in bash Is there a simple way, in a pretty standard UNIX environment with bash, to run a command to delete all but the most recent X files from a directory?  To give a bit more of a concrete example, imagine some cron job writing out a file (say, a log file or a tar-ed up backup) to a directory every hour. I'd like a way to have another cron job running which would remove the oldest files in that directory until there are less than, say, 5.  And just to be clear, there's only one file present, it should never be deleted. Syntax highlighting with less, trouble with lexer I have installed python-pygments and using it for syntax highlighting with less as described by mankoff  I put a function in my .bashrc  cless () {     pygmentize -f terminal "$1" | less -R }   it is enabling syntax highlighting with less. But when I am going to open a file like /etc/fstab or /etc/apt/apt.conf a error saying  Error: no lexer for filename '/etc/apt/apt.conf' found   I found option to show pygmentize the lexer with -l at this . But what will be the appropriate lexer for such files? and how to use it? Is ignoring emails acceptable in academia? As a grad student, I just find it tremendously frustrating when emails are ignored by faculty (both at my institution and at other places). Is this acceptable? I'd be content with a simple response with one line along the lines of "I have read this email and am busy right now, will respond in X days when I can write a more detailed email." I understand that, as a first year student in my field, I'm not really in a position to request anything of anyone, but it just seems like common decency.  Instead, I never hear back, as if my email has been jettisoned off into oblivion. Background  Recently  was implemented. With this feature the amount of questions with new activity is shown in parenthesis at the beginning of the page title, e.g.     (2) Meta Stack Overflow   means that MSO has two questions with new activity since the user last viewed it.   this feature is unrelated to inbox updates. Here is an example to illustrate this:    Even though there are two inbox messages in this screenshot this is not reflected by the page title. The page title is currently only sensitive to questions with new activity.  Suggestion  I suggest that the page title also reflects inbox updates. For the screenshot above this would mean that the page title shows that there are two inbox updates and two questions with new activity.  I am not sure what format is best for showing this. For chat * in the page title is used to show that there are messages directed at you which is similar in meaning to inbox updates. However, * if is placed after the number in parenthesis to denote inbox updates there might be confusion as there is no connection between the number in parenthesis and * like in chat. Thus, one might prefer another format such as one of the following (all are meant to reflect the status of the screenshot above):      * (2) Meta Stack Overflow     2* (2) Meta Stack Overflow     [2] (2) Meta Stack Overflow     2i 2q  Meta Stack Overflow     (2/2)  Meta Stack Overflow     (2|2)  Meta Stack Overflow    For the alternatives without an explicit hint of which number refers to what it might be best to place the number for questions with new activity first as it will in most cases be greater. This will to a greater degree avoid combinations such as "(0/2)" which may be confused zero of two.  An advantage of the suggested feature is that if the user has a browser tab with a Stack Exchange site then they will be instantly notified of inbox updates. They do not need to focus a tab with a Stack Exchange site to know if there are inbox updates, they merely have to check the relevant page titles among their tabs.  A disadvantage of the suggested feature is that it might be experienced as verbose. I suggest that it is implemented such that it is as unobtrusive as possible while still being informative. Think of a situation where a user has   one Meta Stack Overflow tab with two inbox updates relating to Meta Stack Overflow and two questions with new activity, and one Super User tab with one inbox updates relating to Super User and three questions with new activity.   Then the sum of the inbox notification in the page titles should be local to sites and not global. The page titles for the tabs above should be something like the following pair:      2i 2q  Meta Stack Overflow     1i 3q  Super User I vaguely remember a SciFi novel from my younger days, where scientists discover "alternative" forms of power beside electromagnetism.  I do not remember the specific forms, but it was something along the lines of "electrogravity", "magnetogravity" etc. -- you get the idea. If I remember correctly, the effects of these power forms were basically psionic / magic in nature.  Unfortunately I remember very little of the actual plot, and couldn't put it into words with any coherency. Some treachery from within the group of scientists, perhaps some involvement of aliens? I cannot really remember. I just remember I enjoyed the story very much, and would like to re-read it.  The title could be "The fifth column" or similar -- then again I might be confusing two seperate novels.  I know that's not much, sorry. Anyone remembers this? Appending the same string to a list of strings in Python Why is current a scalar quantity? When traveling to a country with a different currency, how should you take your money? Recently my wife and I traveled to Italy and before we left we got about 85% of our money in travelers checks and the other 15% we carried on in cash. When we arrived there, no one would take our travelers checks and many places did not accept credit cards. Eventually, we found some currency exchange places that would take the travelers checks and give us Euro's, but at a 7-15% fee, which was not really a very fun surprise.   While I was under the impression that it is safer to use travelers checks, it seems that they were not really accepted (the usual explanation being fraud). So the question is, is it best to just exchange your currency at home and carry all of it with you when you travel or are there other alternatives to carrying cash that are safer and cost effective? SSL certificate for a public IP address? Gay rights – does Star Trek ever address this issue? I am aware of the picture of the man wearing the 'dress' from TNG, which promotes gender equality, but are gay rights ever addressed in Star Trek at all? (All seasons accepted.) I have a number of friends on my battle.net account. However, sometimes I don't want to appear online to some (or all) of them. Is there a way to be hidden from your friends on battle.net? Windows utility to render which key I am pressing on-screen In H. P. Lovecraft's The Case of Charles Dexter Ward, Dr. Willett      Enters Joseph Curwen's dungeon and resurrects a dead person identified as No. 118 by reciting the incantation of the Ascending Node over his salts.   Dr. Willett is told by      The resurrected Joseph Curwen, impersonating Charles Dexter Ward, who he secretly murdered,   that   " 'twas Number 118, and I conceive you would have shook had you looked it up in my list in t'other room."  No. 118 himself gives Dr. Willett a note asking the doctor to      kill Joseph Curwen.   It soon becomes clear that No. 118 is opposed to the nefarious dealings that have been transpiring and desirous of being an ally of Dr. Willett.  Who is No. 118?  Earlier in the story,      The grave of Ezra Weeden, a primary instigator in Joseph Curwen's initial downfall and the romantic rival of Curwen, is robbed. There doesn't seem to be any other mention of Weeden in the 20th century occurrences, so without a further connection the passage seems superfluous.   The shared goals of these two people seem to indicate that No. 118 may, in fact, have been that person, but the      Note given by No. 118 to Dr. Willett in eighth century Latin seems to indicate someone much older than Ezra Weeden.   It also occurred to me that No. 118 could be      The recently murdered Charles Dexter Ward himself. Ward's reference to killing Dr. Allen (who is actually an alias of Curwen) and dissolving his body with acid and No. 118's mention of doing the same to Curwen seem to support the idea, but that still doesn't explain the archaic note. Ward is described as writing in a somewhat modern style, at least as opposed to Curwen. It also doesn't explain why Curwen would want to murder Ward if he was going to resurrect him later anyway.