I'm trying to make a infix to post fix converter but the problem is that I keep getting null pointer excpetion with input like 3+1 or just (3+1) but I dont really understand what is wrong with the code.  line 26 and 38 are causing the NPE I used the debugger and i know that at that point the stack and queue isnt fillled with anything so they are both null but can i not use =! if it's pointing to null Can you not use something like ops.top.data!="(" if theres a possibility that the top of the stack(ops) is null. heres the code below. I have a seperate stack class that has a top node and queue class with front and rear node.  import java.util.StringTokenizer; import acm.program.ConsoleProgram;  public class In2pJ extends ConsoleProgram{      public void run() {         //fields, 2 queue for input and output, 1 stack for operators, to keep find precedence, use index of strings and divide by 2         Queue input = new Queue();         Queue output = new Queue();         Stack ops = new Stack();         String oppre = "-+/*^"; //index divide by 2 create precedence of 0,0,1,1,2         String paren = "()";         println("Infix to Postfix Converter");         String str = readLine("Enter string(blank line to exit):");         StringTokenizer st = new StringTokenizer(str, "+-*/()", true);         while(st.hasMoreTokens()) {              input.enqueue(st.nextToken());//put tokens into input queue         }          while(true) {             String cur=input.dequeue(); //get a token from input             if(oppre.contains(cur)) {//if token is operator                 //if operator at top of stack has greater precedence or equal but the token is left associative, and the operator at top of stack is not a (                 //pop operators from stack to output queue                 while((oppre.indexOf(ops.top.data)&gt;oppre.indexOf(cur)||(oppre.indexOf(ops.top.data)==oppre.indexOf(cur)&amp;&amp; cur!= "^"))&amp;&amp;ops.top.data!="("){                     output.enqueue(ops.pop());                  }                 ops.push(cur);               }else if(paren.contains(cur)) {//if token is  ()                 if (cur =="(") {//if ( push it onto stack                     ops.push(cur);                 }else {//if )                     //pop operator from the stack onto output if top of stack is not a left paren                     while(ops.top.data!="(") {                         output.enqueue(ops.pop());                     }                     ops.pop();//discard left paren when found                 }             }else if(input.front==null &amp;&amp;input.rear==null) { //if input is empty pop operator from stack to output queue                 while(ops.top != null) {                     output.enqueue(ops.pop());                 }                 break;             }else {//if its a number push it to output queue                 output.enqueue(cur);             }         }         print("Postfix:");         while(output.rear!=null) {              print(output.dequeue());         }     }   }
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?
Book about a boy who travels to a parallel universe to get a book I can't remember the gender of the main character.  I remember bits and pieces from different books, but I think they're all part of the same series. The pieces may not be in order or from multiple books.   Boy somehow ends up in a mirror universe that's darker and seems to have no people. He has to travel to a certain office(?) building and steal a book. I think this is towards the end of the book (I can't remember the events leading up to it). I think he finds the portal in a forest or something behind his school. He goes into the ocean with mermaids or something and has to save the ocean from pollution. Aliens exist and are observing Earth, because they think it's undeveloped and are waiting for them to be advanced enough. His mother ends up in hospital and he does something to save her. He goes to Ireland(?) and enters a mountain or something to find a race of people. I can't remember who showed him how, but I'm pretty sure she used magic. He goes to Mars and saves a race from war with themselves(?). This place was hidden inside an illusion. He's also grouped with a linguist that learned their language. He travels to another world where there's a prince. I can't remember, but I think it might've been part of a tournament. His sister goes to a robot planet through a portal. I think the actual planet was a robot/AI and had lots of little robots on it. Can't remember what happens here, but he goes there and saves her from something.   It was set a few years ago, when computers weren't common (his family got one early in the first book, I think).  Thanks in advance if someone finds it. How to parse hundred html source code files in shell? Uninstall apps locked by phone vendor Where does Google Chrome automatically save pages? I opened the following page:   When disconnecting WiFi and even after rebooting the mobile phone, the page can still be read due to being saved automatically.  Left to the URL bar, an indicator looks like this:  This also shows up when opening manually saved pages, which are saved as MHTML files in the default download folder.  However, an automatically saved page can not be re-downloaded manually to get to the download folder, because the arrow is greyed out.I wish to copy some automatically saved pages into the download folder.  Where are the files of automatically saved pages stored? Get list of all tables in Oracle? How do I query an Oracle database to display the names of all tables in it? What software is used to generate the reputation graphs on Stack Exchange? I'm particularly interested in the zooming functionality which is done very well. Were these graphs generated using off the shelf software or were they coded from scratch? How to delete OS from boot menu After installing fedora and Centos and other OS now I have them all showing in my Boot menu [F2] on start up not the menu form the OS even after deleting them and reinstaling other OS - Ubuntu -so It just shows one when the OS starts but when I go to UEFI setting I still find all the old ones they instruct you to use DEL to take them out but that does not work In the sentence-     You must wear a suit to an interview   shouldn't the to be replaced by for? Or what's the difference between these two here? Learning development with Force platform. Any good books? I'm a bit familiar with Java and SQL, any good books to get on coding in Apex for salesforce? List View Visibility How to show that there is an element of order $51$ in the multiplicative group $(Z/103Z)^∗.$  I can't use Cauchy's theorem since $51$ is not prime. How to search for all questions with bounties across the network? I wanted to search for questions on all SE sites that had a bounty. I am not sure if it is possible, and if it is how can I?   I have seen other questions that show how to find questions on each individual site, but how can I find all of them in one search from the homepage stackexchange.com? If this has been asked already, please let me know.  It has been suggested that the question was already asked (click  for the question), but that question only showed how to find those questions on each separate site or some complex way to search. I am hoping to find a way to search for bountied questions easily or for someone to create a way to do this. I tried to install OracleJDK 8 using   sudo add-apt-repository ppa:webupd8team/java   But it's not working.   I searched the problem and found that      "The Oracle JDK License has changed for releases starting April 16, 2019." And  "Oracle Java (JDK) 8 Installer PPA (DISCONTINUED)"   So I installed the OpenJDK8 .   But why oracle cancelled the license of oracle 8 installer? How can I revert a config file back to the originally installed version after I have edited it? I want to revert a file in /etc/ back to its originally-installed form. I have edited the file since it was installed. How can I revert this config file? Apt is smart enough not to overwrite edited config files, so how do I tell it that I want it to do so?  For argument's sake, let's say that I want to revert the file /etc/foo.conf from the package foo. Prove $0! = 1$ from first principles Will my device work with Ubuntu? When my receiver that I have hooked up to my pc turns on it causes my monitors to turn black is there a way to stop this? Trackpad not working after update to Ubuntu 14.10 on Dell Inspiron 15R Make account merges propagate to chat When two accounts are merged, all the posts/votes are moved over to the "master" account, and the other account ("slave"?) is deleted. The merge is propagated network-wide, so a similar thing happens on each site.  But, this does not happen to the chat user. The "slave" chat user is kept, with a 404 parent profile link. I feel that the chat user should be merged as well, re attributing all the chat messages.  Thoughts? Elysia cron module does not execute cron job automatically I have installed the elysia cron module and setup the cron job. My module has a cron function test_cron() which inserts some data into a table.  This function lists in the elysia cron status page. I have setup the the default scheduled rule to */1 * * * * to run the cron after every minute.  When I click on the run infront of the test_cron() the cron runs and some data inserts into the database.  But this the manual method, I want to execute the cron after every minute therefore I defined the scheduled time for the test_cron(),  but it does not executed automatically after every minute.  What should I do? Is there any other configuration which I should do to run the cron automatically?