The question is Roman to Integer : . Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. So I used toCharArray() method in my answer first.  public int romanToInt(String s) {       HashMap&lt;String, Integer&gt; dict = new HashMap&lt;String, Integer&gt;();         dict.put("I", 1);         dict.put("V", 5);         dict.put("X", 10);         dict.put("L", 50);         dict.put("C", 100);         dict.put("D", 500);         dict.put("M", 100);          int sum = 0;         char[] arrayS = s.toCharArray();         for(int i = 0 ; i &lt; arrayS.length ;  i++){             int Val1 = dict.get(arrayS[i]).intValue();             if(i &lt; arrayS.length -1){             int Val2 = dict.get(arrayS[i+1]).intValue();                 if(Val1 &lt; Val2){                     sum += Val2 - Val1;                     i++;}                 else                     sum += Val1;             }             else                 sum += Val1;          }          return sum;       }   Then in the position int Val1 = dict.get(arrayS[i]);, the complier shows Line 19: java.lang.NullPointerException. However, if I rewrite it without toCharArray(), it works.  int sum = 0;         int val1, val2;         for (int i = 0; i &lt; s.length(); i++) {             val1 = map.get(s.charAt(i));             if (i &lt; s.length()-1) {                 val2 = map.get(s.charAt(i+1));                 if (val1 &gt;= val2) {                     sum += val1;                 } else {                     sum += (val2 - val1);                     i += 1;                 }             } else {                 sum += val1;             }                    }         return sum;   Why do I meet java.lang.NullPointerException problem when using toCharArray()?
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've seen plots of test/training error suddenly dropping at certain epoch(s) a few times during the neural network training, and I wonder what causes these performance jumps:    This image is taken from Kaiming He's Github, but similar plots show up in many papers. Using $g = \frac{Gm}{r^2}$, the force on a point mass located at 1 AU from the Sun ($m = 2 \cdot 10^{30} \text{ kg}$) is about ~0.006 N/kg.  Does that mean that, e.g., a 70 kg person is ~42g lighter during the day, and ~42g heavier at night? That seems like it could make a big difference for things like measuring gold bars or other weight-sensitive items. (Gold arbitrage: buy your gold during the day and sell it during the night! Risk-free profit!)  This makes me suspect that I'm overlooking something obvious, because a ~0.05% weight difference seems like something everyone would have noticed long ago. So what am I missing?    Edit: A few answers below indicate that there shouldn't be any weight difference, because the Earth orbits the Sun in free-fall. But if that's the reason, does that mean that a 1:1 tidally-locked Earth-Sun system wouldn't experience differential gravity from the Sun on opposite sides? That doesn't seem right. I'd like to use JavaScript to calculate the width of a string. Is this possible without having to use a monospace typeface?  If it's not built-in, my only idea is to create a table of widths for each character, but this is pretty unreasonable especially supporting  and different type sizes (and all browsers for that matter). I have a PDF with 100 pages. How can I make a new PDF that displays 4 pages on one?  I know that I can do it with Chrome by printing the PDF to new PDF and change this in the options. But I want to make it for a lot of files and put it as a script. Basic mathematical induction regarding inequalities How do I change file permissions on a FAT32 drive? If $X$ is a Banach space, and $T:X \to X$ is a bounded linear operator with norm &lt; $1$, then $I-T$ has a bounded inverse defined by $(I-T)^{-1} = \sum_{n=0}^\infty T^n$.   Thinking in terms of a converse, if $T$ is any bounded linear operator defined on $X$, then does the existence of a bounded inverse $S=(I-T)^{-1}$ imply that $S$ can be represented as $S=\sum_{n=0}^\infty T^n$? How to enclosure a text block into big square brackets? everybody.  I need to enclosure a text block into big square brackets.  Something like this (I need to replicate it, more or less):   I've read that it could be possible with tikz but I don't know anything about that package.  Even, I found a code that reproduce something similar but with braces in this post:  The code is this:  \documentclass{article} \usepackage{lipsum} \usepackage[many]{tcolorbox} \usetikzlibrary{decorations.pathreplacing}  \newtcolorbox{rightbrace}{%     enhanced jigsaw,      breakable, % allow page breaks     frame hidden, % hide the default frame     overlay={%         \draw [             fill=none, % fill paper             decoration={brace,amplitude=0.5em},             decorate,             ultra thick,             gray,         ]         % right line         (frame.north east)--(frame.south east);     },     % paragraph skips obeyed within tcolorbox     parbox=false, }  \begin{document}  \begin{itemize}     \item First line           \begin{rightbrace}             \item Second line              \item Third line, which is quite long and seemingly tedious in the extreme             \item Fourth line, which isn't as long as the third            \end{rightbrace}     \item Fifth line \end{itemize}  \begin{rightbrace}     \lipsum[1] \end{rightbrace} \lipsum[2]  \end{document}   How could I put the square brackets around a block of text? (Using tikz, tcolobox or whatever package then can be useful for it).  Thanks for your help. I wonder if this is a bug, or if I missed something... When a light hits tangentially convex surfaces with "smooth shading", the shadow on this surface seems to "partially ignore" the smoothness of the surface. Here is an example with a simple cylinder :    On the left, a cylinder with "flat shading". Everything's ok. On the right, the same with "smooth". We can see an edge, bad shadowed.  With or without the "Edge split" modifier, no matters, the edge is still there. The shader is a simple white diffuse shader with no texture nor displace.  I have to add a subsurf modifier with at least 2 levels, which will insanely increase the vertex count... And I can't do that for my project.  I hope someone already saw it, and have a little tip to share. Or if someone already know it's a bug, or a limit of the current Cycles renderer ? Is it possible to construct an (asymmetric) encryption scheme from a signature scheme?  If the signature scheme is deterministic and allows  (e.g. ), then the answer is yes (create a forgery (m, sig); encrypt plaintexts using  with sig as the key; send m in clear to the signer along with ciphertexts, who can then compute sig and decrypt these ciphertexts) .  I am interested in similar reductions for probabilistic signature schemes.  What should the properties of a probabilistic signature scheme be so that it can be used for encryption? I'm trying to enable alsa on different prefix than default through winetricks.  More specifically, the prefix that has Rosetta Stone on it, as it cannot see my microphone.  When I open winetricks, it only lets me select default.  I tried anyway, on default, and it did not resolve the issue.  I saw some answers online, through the terminal, but that didn't work either.  Maybe I have the syntax wrong?  steve@stevelap:~$ WINEPREFIX=~/.PlayOnLinux/wineprefix/Rosetta sh winetricks alsa sh: 0: Can't open winetricks steve@stevelap:~$ sudo WINEPREFIX=~/.PlayOnLinux/wineprefix/Rosetta sh winetricks alsa [sudo] password for steve:  sh: 0: Can't open winetricks   Could anyone please offer assistance?  Thanks! dpkg: error: dpkg status database is locked by another process Is it okay to use my US visa after a name change? I had my US visa about 7 month age, and I had to renew my passport for certain circumstances, so there was a mismatch in the name between both the visa and the new passport, you see they had to put my grand grandfather's name which was not on the old passport nor the visa, the name on old passport and visa is: Abdelrahman Samy Ali Mohammed and the new passport is: Abdelrahman Samy Ali Ibrahim Mohammed. My grand grandfather's name is Ibrahim, so the question is that gonna cause me any troubles concerning my entry to the US? is there any document should I consider taking it while i'm traveling?  Thanks,, Can I update an early Airport Time Capsule? Limit of $s_n = \int\limits_0^1 \frac{nx^{n-1}}{1+x} dx$ as $n \to \infty$ Let $s_n$ be a sequence defined as given below for $n \geq 1$. Then find out $\lim\limits_{n \to \infty} s_n$.   \begin{align}   s_n = \int\limits_0^1 \frac{nx^{n-1}}{1+x} dx  \end{align}  I have written a solution of my own, but I would like to know it is completely correct, and also I would like if people post more alternative solutions. How does Windows know whether it has internet access or if a Wi-Fi connection requires in-browser authentication? In Windows 7, the notification area networking icon will show an error indicator if there is no internet access , and the error icon goes away once there is a successful connection to the internet . Sometimes, if the WiFi connection requires an in-browser authentication step, like on many guest networks in hotels or universities, then the following pop-up bubble appears, saying as much:    How does Windows know whether or not it has a successful internet connection? Presumably it is checking some online Microsoft service to see whether it has a successful connection, gets redirected to some other page, or doesn't get any response at all, but I haven't seen anywhere that this process or the services used are documented. Can anybody explain how this works? I would prefer answers that refer to facts, rather than just guessing, but if you have a really good guess, then go for it.     This question was a .   Read the May 16th, 2011  for more details or  Question of the Week. OAuth redirect URL is not honored Does someone knows if it exists some ppa packages source for the newest Ubuntu version 19.10 i had problem with that when i upgraded from Ubuntu 19.04 to 19.10 i didn't work? Where can I buy an Ubuntu Phone? I need to buy an Ubuntu phone, where can I buy it? It is unavailable everywhere. Find the area ratio between ABC and the hatched triangle. Could you help me?  Find the area ratio between ABC and the hatched triangle.    Thanks in advance.