Edit: It's not something as simple as a nullpointerexception being thrown. The thread is working severable times before throwing the nullpointerexception meaning that it suddenly decides to stop working and I can't figure out why  Hello I have the following thread  private class IsCreditAdded implements Runnable{     ActionEvent evt;      public IsCreditAdded(ActionEvent evt){         this.evt = evt;     }      @Override     public void run(){         while (AddMinutes.creditChosen != true){         }         creditAdded(evt, AddMinutes.getEvt());      } }   It waits for a boolean to change from a GUI class with options to select a value, and then when the boolean changes it executes a method called creditAdded with values evt(passed in from constructor), and a static getMethod which contains the ActionEvent which was selected  public void creditAdded(ActionEvent evt, ActionEvent duration){     System.out.println(evt.getActionCommand() + " " + duration.getActionCommand());     switch (evt.getActionCommand()){         case ("voipCredit"):             switch (duration.getActionCommand()){                 case ("cancel"):                     System.out.println("CANCEL");                     disableButtons(evt, duration);                     break;             }     addMinutes.dispose();     AddMinutes.reset();     sessionStorage.printTransActions(); }   Here is where the thread is created:  private void creditButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                   switch (evt.getActionCommand()){         case ("voipCredit"):             addMinutes = new AddMinutes();             addMinutes.setService("VOIP");             addMinutes.setVisible(true);             addMinutes.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);             addMinutes.setPrices(nf.format(SessionPrices.getVOIP_10_MINS()), nf.format(SessionPrices.getVOIP_30_MINS()),                      nf.format(SessionPrices.getVOIP_1_HOUR()), nf.format(SessionPrices.getVOIP_ALL_DAY()));             threadVar = new Thread(new IsCreditAdded(evt));             threadVar.start();               disableAllButtons();             break;     } }   Now the problem Im having is whenever I select the button which gives the getActionCommand 'cancel' it works two times, sometimes three, but then if I try it again I get a nullpointerexception. The actual error message I get is:     Exception in thread "Thread-6" java.lang.NullPointerException        at com.aidanmoore.InternetCafeGUI.creditAdded(InternetCafeGUI.java:416)        at     com.aidanmoore.InternetCafeGUI$IsCreditAdded.run(InternetCafeGUI.java:411)        at java.lang.Thread.run(Thread.java:745)        BUILD STOPPED (total time: 9 seconds)"   I can't figure out why it is throwing this exception after hours of searching for similar problems others have had and since the thread works x amount of times before throwing the exception I Cant work out why it suddenly breaks
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 is the maximum party size and the corresponding monster buffs? What is the maximum party size (if there is one) in Diablo 3?  Additionally, how much of a buff do monsters get when adding party members?     "A new ally has joined, but the minions of Hell grow stronger." How do I clear keyboard/autocorrect history on the Galaxy s4? I let my younger cousins play on my S4 from time to time, but now I have found that all the words they have used are the first to come up when I use my phone to text. It has gotten quite irritating. Samsung seems to have very hard to find settings compared to my old Sony Ericsson so I cannot find where to get rid of the word history typed onto my phone's keyboard. How to revert to factory settings? This is a repost with additional info of an older question that was never answered. I have stumbled upon this old question while also trying to find the name of the book series myself, as I dearly wish to read it again but for the life of me, I can't remember the name of it.      This is a long shot but I'm really in need of help for this because      it was an amazing book. It was either a kid's or YA book. A guess      from what year it was published would be 90s-mid 2000s, as I read it      around 2008-2011.         The book cover was in first person view, with the main character   holding a weapon, and was a 3D rendered image inside a dungeon or   cave (that was very reminiscent of early 90s CGI animation), though   there may be variants.    It would have been set around when computer   games were mainstream (maybe around the same time as when it might've   been published) It's about a teenage boy who is bored at home, so he   looks through an old family computer to play a game and finds one   that he has never seen before. When he plays it he gets transported   into the game which is a fantasy-medieval setting.    All that I can   remember about the game and story is that the main character is on a   quest, he rides horses a lot, (to the point where he can ride horses   perfectly in real life), at one point he eats food at an ingame   tavern/restaurant? and he tosses the ingame coin currency at the   server because he's in a hurry, (don't know why I remember that bit   specifically haha), and he meets a gnome/dwarf character who is   helping him on his journey, who has a home in an ingame mountain, and   that time goes faster in the game. (For example, if he spent 5   minutes in the real world, 3 in-game days would have passed)   Sometimes as he's playing something stops him from being able the   play the game for a few weeks, maybe a concerned parent because he's   playing too much or there's a family vacation. I remember during the   time when he's not playing the game he's on a farm and knew how to   ride the horses there.    There was a character in the real world who   was the main character's sibling, relative or friend. They were like   a rival and was also very whiny (to some extent). They were on the   farm as well with him and questioned how the main character knew how   to ride a horse when he had never done it in real life.   This is all I can remember but if you need more specific information I can try and answer. It is definitely not Space Demons or Demons Don't Dream. If anyone knows anything remotely similar please mention it, I would really appreciate it. Thank you!!            Additional info:    It is not an online game or virtual reality game. It was a normal PC game, and all other characters are (I think), just NPCs.  He woke up for the first time in a field/farm and was super confused about what happened and where he was, as he had never played the game before. He is asked a super serious question before starting the game up for the first time, like "are you sure you wish to play ___?", and then he is transported into the game.  He frequently exited the game, to continue his IRL life. And sometimes, he would lose access to the family desktop PC for a couple of days at a time, and when he went back everyone in the game (NPCs), thought he had disappeared because he was gone for ages. I think once, his family when on holidays and he couldn't take the PC, for example.  It was a book series, not a single book. In later books he would play the game again months later in the real world, and years and years would have passed in the game world.  The plot involved 2 main warring sides/factions/countries of humans, but there were fantasy/magical races and characters involved. I vaguely remember something about each side having official colours, one red and one blue. I think the main character was on the blue side.   The original question was never correctly answered, so I'm posting again to see if anyone can remember.   Books that were ruled out in original post: Eden's Gate &amp; Heir Apparent. How to know if Google Sheets IMPORTDATA, IMPORTFEED, IMPORTHTML or IMPORTXML functions are able to get data from a resource hosted on a website? Google Sheets has several import functions   IMPORTDATA IMPORTFEED IMPORTHTML IMPORTXML   Sometimes the above functions returns errors like #N/A Imported content is empty and would like to be sure that there isn't a problem with the resource content to be imported.  How do I know if these functions are able to get the content that I looking to import?  I know that there also exist IMPORTRANGE but that function only is able to import content from Google Sheets spreadsheets Auto size image to page size in InDesign I've got an InDesign document with 100 A4 pages.   I've got 100 assets (a mixture of .jpg and .pdf files) and I want to place 1 per page. If an image is not the proportion of the A4 page I would like to get it as big as it can be on the page before it hits into the margin. Ex. if it's a portrait image it should be as large as it can be before hits the top/bottom margin. If it's a landscape image it should be as large as it can be before hits the left/right margin.   At the moment I'm dragging each file across and resizing them manually. Is it possible just drop them on the page and get them auto resized ? Should my first trip be to the country which issued my Schengen Visa? In case, if I get a multiple-entry Schengen visa in one of the embassies in Ukraine, Kyiv - should my first trip be to the country which issued the visa?  Any there any requirements of this sort? Does this condition vary depending on embassy which issued the visa?  What are the possible consequences on not visiting that country first? Does it somehow depend on country where the embassy is (i.e. non-Schengen and not EU members)? Shortcut or button for copying posted code from Stack Overflow I might just be lazy, but do you ever find it tiresome to select all the source code from a large post on Stack&nbsp;Overflow to copy it?  I would like a feature, possibly a Firefox extension, but preferably a JavaScript script, for automatically copying source examples to the clipboard. It's no big deal for a small snippet, but a 1000+ line posting is cumbersome to copy.  Do you guys have a better way of copying large source posts? I'm using Firefox 3.5.5 on Windows&nbsp;7. Given a file L with one non-negative integer per line and text file F, what would be a fast way to keep only those lines in F, whose line number appears in file L?  Example:  $ cat L.txt 1 3  $ cat F.txt Hello World Hallo Welt Hola mundo  $ command-in-question -x L.txt F.txt Hello World Hola mundo   I'm looking for a command that can handle a file L with 500 million or more entries; file L is sorted numerically.  Note: I'm halfway through an implementation for a command-in-question but I just wondered, whether one might be able to use some Unix tools here as well.    Update: Thank for all the answers, I learned a lot today! I would like to accept more one answer, but that's not possible. Is it possible to assign the same value to multiple keys in a dict object at once? How to add new element to Varargs? Radeon error atombios stuck in loop The screen goes blank and shows logs me out immediately a while after using multiple monitors.   dmesg shows:  [33786.908877] [drm:atom_op_jump [radeon]] *ERROR* atombios stuck in loop for more than 5secs aborting [33786.908901] [drm:atom_execute_table_locked [radeon]] *ERROR* atombios stuck executing 6DD2 (len 254, WS 0, PS 4) @ 0x6DE0 [33786.908910] [drm:atom_execute_table_locked [radeon]] *ERROR* atombios stuck executing 673E (len 78, WS 12, PS 8) @ 0x6777   lspci | grep -E 'VGA|Display' shows:  00:02.0 VGA compatible controller: Intel Corporation HD Graphics 5500 (rev 09) 03:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Sun  XT [Radeon HD 8670A/8670M/8690M / R5 M330 / M430] (rev 83)    explains exactly my situation. But I don't have /etc/modprobe.d/radeon.conf file. Implement multiple inheritance in Javascript Scoring when two triple word squares are covered in one play The word QUAGMIRE is on the board vertically, with the Q on the top row, second column. The next player creates SQUEEZED horizontally, landing the S on the triple word square in the top row, first column, and remaining UEEZED landing to the right of the existing Q, ending with the D on the triple word square in the eighth column. Since two triple word squares are covered in this one placement, how would it be scored?  Letters:   S: 1 Q: 10 U: 1 E: 1 x 2 (double letter) E: 1 Z: 10 E: 1 D: 1   27 Total for letters. Do you then multiply by 3 for the first triple word square, and then multiply that result by 3?  27 X 3 = 81, 81 X 3 = 243  Bonus for all 7 tiles placed:  243 + 50 = 293 Make an object invisible to a specific camera? (Cycles) Say I have this file:  hello world hello world   This program  #!/bin/bash  for i in $(cat $1); do     echo "tester: $i" done   outputs  tester: hello tester: world tester: hello tester: world   I'd like to have the for iterate over each line individually ignoring whitespaces though, i.e. the last two lines should be replaced by  tester: hello world   Using quotes for i in "$(cat $1)"; results in i being assigned the whole file at once. What should I change? dpkg error: "trying to overwrite file, which is also in..." For example:  $ sudo apt-get install curl Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: bsh : Depends: libjline-java but it is not going to be installed groovy : Depends: libjline-java but it is not going to be installed rhino : Depends: libjline-java but it is not going to be installed E: Unmet dependencies.   Try 'apt-get -f install' with no packages (or specify a solution).   I get the same or similar errors when I attempt to install clojure1.3, leiningen, and several other packages.   When I try the suggestion made in the error message, this is what happens:  $ sudo apt-get -f install  Reading package lists... Done Building dependency tree        Reading state information... Done Correcting dependencies... Done The following packages were automatically installed and are no longer required:   diffstat linux-headers-3.2.0-26-generic linux-headers-3.2.0-26 dh-apparmor dkms html2text libmail-sendmail-perl libsys-hostname-long-perl Use 'apt-get autoremove' to remove them. The following extra packages will be installed:   libjline-java Suggested packages:   libjline-java-doc The following NEW packages will be installed:   libjline-java 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. 23 not fully installed or removed. Need to get 0 B/72.0 kB of archives. After this operation, 129 kB of additional disk space will be used. Do you want to continue [Y/n]? Y (Reading database ... 226243 files and directories currently installed.) Unpacking libjline-java (from .../libjline-java_1.0-1_all.deb) ... dpkg: error processing /var/cache/apt/archives/libjline-java_1.0-1_all.deb (--unpack):  trying to overwrite '/usr/share/java/jline.jar', which is also in package scala 2.9.2-400 Errors were encountered while processing:  /var/cache/apt/archives/libjline-java_1.0-1_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)  $ sudo apt-get upgrade Reading package lists... Done Building dependency tree        Reading state information... Done You might want to run 'apt-get -f install' to correct these. The following packages have unmet dependencies:  bsh : Depends: libjline-java but it is not installed  groovy : Depends: libjline-java but it is not installed  rhino : Depends: libjline-java but it is not installed E: Unmet dependencies. Try using -f. I have often wondered at the practice on Stack&nbsp;Overflow, Server&nbsp;Fault, and the other sites where someone will ask a question and an answer will come in that says Look here: http://link elsewhere. Rarely will the link have exactly the answer necessary -- often it's an entire article -- yet these answers get voted up.  Why is that, exactly? I realize this is subjective, but my own thoughts are that one should try and give the answer (even if the answer is 'no, it can't be done' or 'no, I don't think it can be done' -- very different answers) and then if you have a link that explains it, go ahead and post it within the answer.  What does the community think about this?     For more information, see  in the . Specifing ip address for outbound connections on a multi ip host one of my servers (Debian 5.0.6) has two public ip-address on the same interface. This used to work well for months but suddenly it is using "the wrong" ip addresses for outgoing connections. This is a problem because the reverse lookup will not match and emails therefore get spam points.  eth0      Link encap:Ethernet  Hardware Adresse 00:1b:21:14:8e:9c             inet Adresse:81.169.180.51  Bcast:81.169.180.51  Maske:255.255.255.255           inet6-Adresse: fe80::21b:21ff:fe14:8e9c/64 Gültigkeitsbereich:Verbindung  eth0:0    Link encap:Ethernet  Hardware Adresse 00:1b:21:14:8e:9c             inet Adresse:85.214.157.120  Bcast:85.214.157.120  Maske:255.255.255.255   Kernel-IP-Routentabelle Destination     Router          Genmask         Flags Metric Ref    Use Iface 81.169.180.1    0.0.0.0         255.255.255.255 UH    0      0        0 eth0 0.0.0.0         81.169.180.1    0.0.0.0         UG    0      0        0 eth0   Currently it is using 85.214.157.120 for outbound connections. How do I get it to use 81.169.180.51?  Edit: The netmask of 255.255.255.255 is consistent with both documentation and DHCP response of the hosting company. Calling /etc/init.d/networking restart multiple times will eventually end up with the correct ip-address for outbount connections. But that is obviously not a stable solution. /Edit  Edit 2: To make sure that the host route is not related to my issue, I setup a local test network:  eth0      inet Adresse:192.168.0.2  Bcast:192.168.0.255  Maske:255.255.255.0 eth0:0    inet Adresse:192.168.0.3  Bcast:192.168.0.255  Maske:255.255.255.0  192.168.0.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0 0.0.0.0        192.168.0.1     0.0.0.0         UG    0      0        0 eth0   If anyone has an idea how to make sure that source ip-address 192.168.0.2 is used on outbound tcp connections, I'd be thankful. /Edit 2 PHP regular expressions: No ending delimiter '^' found in