Hey guys I am sure there is something obvious here that im just not seeing. I need some help with trying to figure out why I am getting a null pointer exception when I set the game.max value in the GuessingGame3 constructor. It seems like no matter what I do the value will not get set. Even when I explicitly set the value it still throws an error. I've tried changing the max variable to static as well and that didnt work either. A lot of people are saying you need to initialize the value which I did and that didnt work. Please help.     package guessinggame3;    import java.util.Random;    //provides methods that return a random integer in                              //the range 0 to 4294967296.    import java.util.Scanner;   //enable the user to input values from the keyboard     public class GuessingGame3     {        public int max;        public int answer;        public int maxGuessesAllowed;        public int numGuessTaken;        public static int currentGuess;        public static int previousGuess;        public boolean gameOver;        public int differential;        public GuessingGame3 game;  public static void main(String[] args) {      GuessingGame3 game = new GuessingGame3();     game.GuessingGame3(); }  public void GuessingGame3() {     Scanner sc = new Scanner(System.in);     System.out.println("Welcome to the Guessing Game.");     System.out.println("Enter the maximum number:");      game.max = sc.nextInt();              // input maximun number of guesses     Random generator;      // New random number generator     generator = new Random();     game.answer = generator.nextInt(game.max); // the randomly chosen answer     System.out.println("Enter the maximum number of guesses allowed:");      maxGuessesAllowed = sc.nextInt();      game.newGame(maxGuessesAllowed); }  public void newGame(int GuessesAllowed) // Given the max,generate answer {  game.maxGuessesAllowed = GuessesAllowed;  Random generator = new Random();     // New random number generator  int answer = generator.nextInt(max); // the randomly chosen answer  System.out.println("The answer is:" + answer);  game.gameOver = false;  game.differential = game.max;  game.numGuessTaken = 0;  game.guess(); }    public void guess()  {   /* Takes in int answer &amp; returns string response */             Scanner sc = new Scanner(System.in);  while(!gameOver)  {   System.out.println("Enter your guess:");    currentGuess = sc.nextInt();   if(answer == currentGuess)     // correct guess branch    {     gameOver = true;     System.out.println("Congratulations! Would you like to play again?");     System.out.println("Enter Y for yes or N for no.");     String again = sc.next();          again = again.toUpperCase();       if(again.equals("Y"))       {        GuessingGame3 game;        game = new GuessingGame3();        game.GuessingGame3(); //Start a new game       }       if(again.equals("N"))       {        System.out.println("Goodbye.");        break;       }    }         if(currentGuess &gt; answer)      //currentGuess is too high      {       System.out.println("Too high");      }      if(currentGuess &lt;answer)       //currentGuess is too low      {       System.out.println("Too low");      }      if(currentGuess &gt; max)         //currentGuess is beyond the max      {       System.out.print("Your guess is beyond the max you set.");       continue;      }      int differential = Math.abs(answer - currentGuess);      if (game.differential != 0 &amp;&amp; differential &lt; game.differential)         {                                       // If this is the first guess                System.out.println("Getting Warmer");  // there is differential. So no      }                                       // "warmer" or "colder."      if (game.differential != 0 &amp;&amp; differential &gt; game.differential)      {       System.out.println("Getting Colder");         }      game.differential = differential;  } }   }
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 really clear the terminal? I can issue the clear command or press Ctrl + L to clear the current Ubuntu terminal, but this just shifts previous output upwards and if you use mouse scroll or PgUP and PgDown keys it's hard to distinguish where the output of previous command ends and output of current command begins.  Is there a way to really clear the terminal so I won't see previous command results? How can I break an align environment for a paragraph? I would like to have two displayed equations, broken by a short paragraph, but with aligned equal signs (as if using the align environment).  Is there some way to "break" the align environment temporarily? Solving an ODE in power series Why does Li-Po battery voltage drop under load? I have very low background in electronics.  I have a Li-Po battery connected to an electric motor. The question is:   Why does battery voltage drop under load? Why is each cell of a Li-Po battery limited to 3.0 V (discharging)? Why is each cell of a Li-Po battery limited to 4.2 V (charging)? How to remove GNOME Shell from Ubuntu 20.04 LTS to install other desktop environment from scratch? I have just installed the final version of Ubuntu 20.04 LTS desktop system from ubuntu-20.04-desktop-amd64.iso. After two days of testing I completely do not like its graphical interface - the GNOME Shell. Even installation of GNOME Flashback does not help either.  So I want to completely remove the GNOME Shell with all its trails from my system without re-installation. Just want to start from scratch like it was approximately if I have installed Ubuntu from . Why is "No new release found" when upgrading from a LTS to the next? I'm following the , but on launching the upgrade tool I get this response:  Checking for a new ubuntu release No new release found   Am I doing something wrong? Is there a workaround? Prove that $A = B = C = D$ $A, B, C, D$ are sets, where $A \not = \emptyset$ and $B \not = \emptyset$. Equation $(A \times B) \cup (B \times A) = C \times D$ is true.  Prove that $A = B = C = D$.  I tried to find $A, B, C, D$ separately, but that didn't get me anywhere. Any ideas how to solve it? Test statistic for follow up procedure (stepwise step down) of Kruskal Wallis When conducting a Kruskall Wallis test, it is possible to follow up the procedure with a post hoc test, looking for homogeneous subsets. My question is which statistic is used to perform this procedure (e.g., is it Chi-Square, z, or the original H)? Can't upgrade due to low disk space on /boot I try to do do-release-upgrade but then I get:       Not enough free disk space      The upgrade has aborted. The upgrade needs a total of 25.7 M free   space on disk '/boot'. Please free at least an additional 25.7 M of   disk space on '/boot'. Empty your trash and remove temporary packages   of former installations using 'sudo apt-get clean'.   Output of df:                      237251272 214797108  10402504  96% / udev                    488120         4    488116   1% /dev tmpfs                   198676       668    198008   1% /run none                      5120         0      5120   0% /run/lock none                    496684         0    496684   0% /run/shm /dev/sda1               233191    225867         0 100% /boot   How come there is no space left on boot? Here's the output of ls -as /boot:  total 221839     4 .     4 ..   645 abi-2.6.32-34-generic-pae   698 abi-2.6.35-30-generic-pae   727 abi-2.6.38-12-generic-pae   727 abi-3.0.0-12-generic-pae   727 abi-3.0.0-13-generic-pae   727 abi-3.0.0-14-generic-pae   727 abi-3.0.0-15-generic-pae   727 abi-3.0.0-16-generic-pae   727 abi-3.0.0-17-generic-pae   727 abi-3.0.0-19-generic-pae   761 abi-3.0.0-20-generic-pae   115 config-2.6.32-34-generic-pae   128 config-2.6.35-30-generic-pae   136 config-2.6.38-12-generic-pae   140 config-3.0.0-12-generic-pae   140 config-3.0.0-13-generic-pae   140 config-3.0.0-14-generic-pae   140 config-3.0.0-15-generic-pae   140 config-3.0.0-16-generic-pae   140 config-3.0.0-17-generic-pae   140 config-3.0.0-19-generic-pae   140 config-3.0.0-20-generic-pae     5 grub 10773 initrd.img-2.6.32-34-generic-pae 13619 initrd.img-2.6.35-30-generic-pae 15365 initrd.img-2.6.38-12-generic-pae 16481 initrd.img-3.0.0-12-generic-pae 16487 initrd.img-3.0.0-13-generic-pae 16501 initrd.img-3.0.0-14-generic-pae 16476 initrd.img-3.0.0-15-generic-pae 16481 initrd.img-3.0.0-16-generic-pae 16478 initrd.img-3.0.0-17-generic-pae    12 lost+found   174 memtest86+.bin   176 memtest86+_multiboot.bin  1700 System.map-2.6.32-34-generic-pae  1841 System.map-2.6.35-30-generic-pae  2115 System.map-2.6.38-12-generic-pae  2141 System.map-3.0.0-12-generic-pae  2141 System.map-3.0.0-13-generic-pae  2143 System.map-3.0.0-14-generic-pae  2146 System.map-3.0.0-15-generic-pae  2147 System.map-3.0.0-16-generic-pae  2147 System.map-3.0.0-17-generic-pae  2148 System.map-3.0.0-19-generic-pae  2149 System.map-3.0.0-20-generic-pae     2 vmcoreinfo-2.6.32-34-generic-pae     2 vmcoreinfo-2.6.35-30-generic-pae     2 vmcoreinfo-2.6.38-12-generic-pae     2 vmcoreinfo-3.0.0-12-generic-pae     2 vmcoreinfo-3.0.0-13-generic-pae     2 vmcoreinfo-3.0.0-14-generic-pae     2 vmcoreinfo-3.0.0-15-generic-pae     2 vmcoreinfo-3.0.0-16-generic-pae     2 vmcoreinfo-3.0.0-17-generic-pae     2 vmcoreinfo-3.0.0-19-generic-pae     2 vmcoreinfo-3.0.0-20-generic-pae  4092 vmlinuz-2.6.32-34-generic-pae  4347 vmlinuz-2.6.35-30-generic-pae  4567 vmlinuz-2.6.38-12-generic-pae  4675 vmlinuz-3.0.0-12-generic-pae  4676 vmlinuz-3.0.0-13-generic-pae  4681 vmlinuz-3.0.0-14-generic-pae  4698 vmlinuz-3.0.0-15-generic-pae  4700 vmlinuz-3.0.0-16-generic-pae  4700 vmlinuz-3.0.0-17-generic-pae  4703 vmlinuz-3.0.0-19-generic-pae  4705 vmlinuz-3.0.0-20-generic-pae   Output of uname -a:   Linux kitsch 3.0.0-17-generic-pae #30-Ubuntu SMP Thu Mar 8 17:53:35 UTC 2012 i686 i686 i386 GNU/Linux What does this notation mean? $f(x) \equiv A$? If $\lim_{x\rightarrow\infty}f(x) = A$, prove that $f(x)\equiv A$.  Any help would be appreciated! I just don't even understand the question. What if the answers of a historical locked question become obsolete? What is the first reference in Sci-Fi to a touch-screen computer interface? I know in TNG that all computer interfaces are now touch-screen, and that got me thinking: when was the first reference to touch-screen computer interfaces in Sci-Fi made? Displaying and/or searching across thousands of contacts? The Need  Our application has a chat feature that allows our users to chat with other users within their database.   However, we're adding a feature that allows clients to share data between multiple databases as an "Enterprise" configuration, and we've been asked to update the design of the chat feature to allow users to chat with other users within any of those databases.   We've looked at the numbers of possible users in these scenarios, and the number of chat users in these shared database environments can be as many as 5,000.   Users need to be able find people they need to chat with out of these thousands of contacts. However, up til now, we've had a list of contacts the users can browse. Since that is a user expectation, we were hoping to still maintain a browse-able list of contacts. We have ruled out trying to display a list of 5,000 contacts, as this doesn't seem to be anywhere close to useful or usable.   We've come up with three approaches to solve the problem:  Option One  Show a list of contacts from the local database that user's can browse. Have a second tab that allows users to search the "Full Directory", returning results from multiple databases.     Pros:   Allows us to show a browse-able list of relevant contacts  Clearly indicates to users that another source of chat contacts are available   Cons:   Search would be limited to the current tab, meaning users would have to be in the right tab to return the right result Adds a possible source of user confusion: whats the difference between "contacts" and the "full directory"? Adds another tab to what should be a simple chat list     Option Two  Show a list of contacts from the user's local database, but if they search for a contact, include results from other databases as well.     Pros:   Maintains a list of contacts the user can browse Avoids adding adding another tab One search field searches all sources   Cons:   Searching a finite contact list and returning results that weren't in the contact list may defy user's mental model of how the search will work. Not clear that another source of contacts exist. May need to add explanatory text that says "Search to see contacts from the full directory".      Option Three  Add a dropdown that allows a user to select a what to search in: the local database, or the full directory.     Pros:    No additional tab required Indicates to users that another source of chat contacts are available, though not as clearly as option 1   Cons:    Search still isn't universal: the right search category must be selected to return the right result Users may not notice the dropdown or understand intuitively what its function is. May require explanatory text in search results, reminding the user they can expand the search to the full directory     Thoughts?  Right now I'm leaning towards option two, but is there another option I'm not considering here? Is there another alternative worth considering?   Thanks! a, b are integers. p is prime. I want to prove: $(a+b)^{p} \equiv a^p + b^p \pmod p$  I know about Fermat's little theorem, but I still can't get it I know this is valid: $(a+b)^{p} \equiv a+b \pmod p$ but from there I don't know what to do.  Also I thought about $(a+b)^{p} = \sum_{k=0}^{p}\binom{p}{k}a^{k}b^{p-k}=\binom{p}{0}b^{p}+\sum_{k=1}^{p-1} \binom{p}{k} a^{k}b^{p-k}+\binom{p}{p}a^{p}=b^{p}+\sum_{k=1}^{p-1}\binom{p}{k}a^{k}b^{p-k}+a^{p}$ Any ideas?  Thanks! How I can recover files when the folder shows empty but the files are not deleted? $\sum_{n=1}^\infty\frac{z^n}{n}$ does not converge uniformly on $\mathbb{D}$. Is there any relation between the chromatic number of a graph $G$ and its complement $G'$ that are always true?  I saw these ones: $\chi(G)\chi(G')\geq n$ and $\chi(G)+\chi(G')\geq 2n$,  but I'm not pretty sure about them. I have read the Rules of a competition. The text of the Rules include a sentence as follows:     As per stated in the Rules the entrants will be notified by May 30th 2010.   Does the sentence above mean that May 30th is included in the term of notification or not? I had created the xml document with xml version="1.0".  In that document I need to use the greater than symbol &gt; and less than symbol &lt;.  How should I include those symbols? It's not working.  &amp;gt; and &amp;lt; are not working for me.  Is there any special encoder for this? How to pass javascript value to controller..? I want to pass the java-script value to controller.I am using repeat on VF page.  VF page      &lt;apex:repeat value="{!listAdj}" var="Adj" id="hrs"&gt;       &lt;td&gt;&lt;div class="requiredInput"&gt;&lt;div class="requiredBlock"&gt;&lt;/div&gt;     &lt;apex:inputField id="decimal" value="{!Adj.Hours_Decimal__c}" onchange="setHidden5(this);" &gt;       &lt;/apex:inputField&gt;     &lt;/div&gt;&lt;/td&gt;             &lt;apex:inputField id="hours" value="{!Adj.Hours__c}" /&gt; &lt;apex:inputField id="decimal" value="{!Adj.Hours_Decimal__c}" onchange="setHidden5(this);"/&gt;              &lt;/apex:repeat&gt;   Javascript code  function setHidden5(element){     //split the id of the inputField by ':' and then use the 5th index in the array to exact position of the inputField in the apex:repeat.   var idArray = element.id.split(':');     var hiddenRep1 =document.getElementById("thePage:form:hrs:hrs:"+idArray[4]+":decimal");          var hiddenRep2 = document.getElementById("thePage:form:hrs:hrs:"+idArray[4]+":hours");       if(element.value.length &gt;=1){        document.getElementById("thePage:form:hrs:hrs:"+idArray[4]+":hours").disabled = true; **hiddenRep2.value=hidden1.value;**                }                             }     }   I want to pass the hiddenRep2.value to controller.How to pass that. Hidden2.value is same as hidden1.value + some addition subtraction.i dont know how to pass that value. Can someone me sort out this.  Thanks