I'm a Java noobie so I'm still not familiar with the tools this language has. What I'm writing is an expression evaluation program, whose only operations are * and +. For input : 2+2*2*2*2*2*2+2*2 I should get an output of 70 but instead, my main throws a java.lang.NullPointerException where I call the function and where I try to push it on the stack. I've tried using Charachter.valueOf() but the outcome is the same. My questions are:   How to convert a primitive type char to a Character? Why is new Character deprecated?   Here is my stack implementation:   public class MainClass {          //ExpressionEvaluator MainClass       public static int evaluateExpression(String expression){          int evaluation = 0, a = 0, b = 0, tmp = 0;          char ch1, ch2, op;          LinkedStack&lt;Character&gt; operand = null;          LinkedStack&lt;Character&gt; operator = null;          for(int k = 0; k&lt;expression.length(); k++){              if(Character.isDigit(expression.charAt(k))){                  op = expression.charAt(k);                  operand.push(new Character(op)); // &lt;----- then error here             }                                           // won't let me push it on the stack             else{                 operator.push(expression.charAt(k));             }         }         if(operator.peek() == '*'){             evaluation = 1;         }         while(!operand.isEmpty() &amp;&amp; !operator.isEmpty()){             a = operand.pop();                       ch1 = operator.pop();                    if(ch1 == '*'){                              evaluation *= a*operand.pop();             }             else{                                        tmp = a;                                 a = operand.pop();                       ch2 = operator.pop();                    if (ch2 == '*'){                     evaluation *= a*operand.pop();                 }                 else{                     evaluation += a+tmp;                 }             }         }         return evaluation;     }      public static void main(String[] args) throws IOException {         BufferedReader input=new BufferedReader(new InputStreamReader(System.in));         System.out.println(evaluateExpression(input.readLine()));//  &lt;--------   first error here     }  }
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 often have to sort a dictionary, consisting of keys &amp; values, by value. For example, I have a hash of words and respective frequencies, that I want to order by frequency.  There is a SortedList which is good for a single value (say frequency), that I want to map it back to the word.   orders by key, not value. Some resort to a , but is there a cleaner way? Mounting /cow on root failed: Invalid argument overlay mount failed I am using an xps 13 9365, which was data wiped from bios by a friend who then gave it to me thinking it was dead. I tried booting with a USB (current LTS distro (18.04 or similar)) boot disk and got into the language selection / setup menu. By using the F6 option I selected noapic. In bios sata is set to raid and legacy the secure boot option is off.   But when I try to install I get kicked into a tiny font window with the following message  (initramfs) mount: Mounting /cow on root failed: Invalid argument overlay mount failed  Any ideas? I know that the compiler will sometimes initialize memory with certain patterns such as 0xCD and 0xDD.  What I want to know is when and why this happens.  When  Is this specific to the compiler used?  Do malloc/new and free/delete work in the same way with regard to this?  Is it platform specific?  Will it occur on other operating systems, such as Linux or VxWorks?  Why  My understanding is this only occurs in Win32 debug configuration, and it is used to detect memory overruns and to help the compiler catch exceptions.  Can you give any practical examples as to how this initialization is useful?  I remember reading something (maybe in Code Complete 2) saying that it is good to initialize memory to a known pattern when allocating it, and certain patterns will trigger interrupts in Win32 which will result in exceptions showing in the debugger.  How portable is this? Wrap text at any point if normal hyphenation not possible How does centering the data get rid of the intercept in regression and PCA? I keep reading about instances where we center the data (e.g., with regularization or PCA) in order to remove the intercept (as mentioned in ). I know it's simple, but I'm having a hard time intuitively understanding this. Could someone provide the intuition or a reference I can read? How to change the camera from Landscape to Portrait I need a way to render a picture that is longer heighth-wise than width-wise. Changing the scale of the camera does nothing. I've been told to look in the scene focus settings, and I didn't see anything. Is there a way to change the shape of the rendered image? The 3 different equals Is it true every ideal of $\mathbb{Z}[x]$ is finitely generated? Let $I$ be any ideal of $\mathbb {Z}[x]$, and $I=\left&lt;{f_1,f_2 , ...}\right&gt;$.  Without loss of generality, $f_1$ has minimal (absolute value) coefficient of constant term (if there exist).  Then, let $g$ be any element of $I$ .  We have for some integer $m$ that $g - mf_1$ is element of $I$ (minimal coefficient and division algorithm).  I guess this process terminate finitely, but I don't know how can I do next step.  ( ex. $g-mf_1, g-mf_1-nf_2, ...$)  Please help me and thanks for in advance. If $x\sqrt{1+y}+y\sqrt{1+x}=0$ find $y'$ Find $\frac{dy}{dx}$ if $x\sqrt{1+y}+y\sqrt{1+x}=0$ for $-1\leq x\leq 1$   My Attempt $$ x\sqrt{1+y}=-y\sqrt{1+x}\implies x^2(1+y)=y^2(1+x)\implies x^2+x^2y=y^2+xy^2\\ 2x+2xy+x^2\frac{dy}{dx}=2y\frac{dy}{dx}+y^2+2xy\frac{dy}{dx}\\ \frac{dy}{dx}\Big[ x^2-2y-2xy \Big]=y^2-2x-2xy\\ \frac{dy}{dx}=\frac{y^2-2x-2xy}{x^2-2y-2xy} $$ How do I proceed further and find the derivative ? What equipment should I have to kill the Eye of Cthulhu? I just manually summoned the Eye of Cthulhu, going into battle with copper armour, tungsten broadsword, gold bow, jester arrows and plenty of lesser healing potions. I came rather close to death but I managed to stay alive. However, the Eye took off when I had his health down to ~1700. I'm assuming this means you only have a few minutes to finish it off after a certain point. Is there any equipment I'm missing to help kill the Eye faster and to help my survivability? If it's relevant, my current life is 120. How to install apk in 2nd user of android 5.0 without playstore So, android 5.0.2 doesn't allow side loading of apks for 2nd user (irrespective of whether it is guest or standard user). "Unknown Sources" is disabled and is uncheckable. And I use a pure Cyanogen Mod 12 (android 5.0.2) without any Google apps. So, there is no Play Store app.  But I have root access.  As shown in the pics, Unknown Sources is Uncheckable and installation is blocked.  (Click image to enlarge)     With this situation, how can i install apks on to the 2nd user account??  EDIT:   It seems Google intentionally (in the name of security) blocked sideloading apks for 2nd user in android 5.0.2. There is a bug report . And sideloading was reenabled in android 5.1.   I will post how to sideload apks on lolipop 2nd user using adb. If this can be done without adb please post. I want to shrink my second (LVM) partition, in order to create a new partition in the newly freed space. I am using the Live CD to do so, because I know I can't resize/move this partition while it is in use. When I opened GParted in the Live CD, I realized that I could not resize the partition, because when I right-click it, the option "resize/move" is disabled.  I tried to unmount it, to "lazy" unmount it (umount -l /dev/sda2) but it didn't work.  A screenshot from GParted: So, somehow over the weekend, my 1GB USB flash drive has managed to become write-protected.  There is no switch on the stick, so I'm concluding that something has corrupted at some point.  Obviously I can't format it or remove.  The output from dmesg | tail is:  Buffer I/O error on device sdb1, logical block 328168 lost page write due to I/O error on sdb1 sd 73:0:0:0: [sdb] Unhandled sense code sd 73:0:0:0: [sdb] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE sd 73:0:0:0: [sdb] Sense Key : Data Protect [current] Info fld=0x0 sd 73:0:0:0: [sdb] Add. Sense: Write protected sd 73:0:0:0: [sdb] CDB: Write(10): 2a 00 00 05 08 00 00 00 01 00 Buffer I/O error on device sdb1, logical block 328200 lost page write due to I/O error on sdb1   I think the second and final lines are a giveaway to corruption, but I don't know how to interpret this output.  Could someone help to see if this output gives any indication?  I usually eject the drive before removing it, but I may have been lax once or twice.  The data isn't critical, it's just bugging me.  Any suggestions on how to fix it (if the drive even can be) would be greatly appreciated. Going into a directory linked by a link I am interested in theoretical and practical considerations. Is there a way to rename (or do away with the name of) the bibliography page that is output using BibTeX?  If so, is the name dependent on the bibliographystyle, or is it something inherent within the BibTeX functionality? Dynamic dispatch and binding How to delete a full stop on reference ending According to APA rules, after each reference there must the digital object identification (doi). I use JabRef as a reference manager and for some reason, if I put an article doi on its "doi" field, it won't show up after the build on my editor, but if I put the doi on its "note" field it shows up. However, it's adding a period after the note field. I need a way to have the reference without an ending period.  Here's the LaTex document. I use TexPad as my editor.  \documentclass[12pt,a4paper,oneside]{report} \usepackage[utf8]{inputenc} \usepackage[portuguese, english]{babel} \usepackage[T1]{fontenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage[sort, longnamesfirst]{natbib} \usepackage[strings]{underscore} \bibliographystyle{newapa}  \usepackage{sectsty} \chapterfont{\fontsize{14}{15}\selectfont} \sectionfont{\fontsize{12}{15}\selectfont} \subsectionfont{\fontsize{12}{15}\selectfont} \renewcommand\bibsection{\section*{Referências}} \bibpunct[:\ ]{(}{)}{;}{a}{,}{,}  \title{} \date{} \makeindex  \begin{document}  \cite{aldous-newviewsgrandparents-1995}  \bibliography{/Users/Ricardo/Documents/Ricardo/library2.bib}  \end{document}   It produces this:     Aldous, J. (1995). New views of grandparents in intergenera- tional   context. Journal of Family Issues, 16(1), 104–122. doi:   10.1177/019251395016001006.   I need that last period out.  Thanks. How to auto close LWC quick action from JavaScript? Some ships in Star Trek are referred to with definite articles. "The Enterprise", "The Defiant". Other ships are referred to without them. "Voyager", "Enterprise". Is there a pattern to or explanation for this behavior?