I have the below code:   import java.util.HashMap;     import java.util.Map;      public class Pangram1 {          public static void main(String[] args)         {         Character [] ch = new Character[] {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};         HashMap&lt;Character,Integer&gt; map1 = new HashMap&lt;Character,Integer&gt;();         String s = "The quick brown fox jumps over the lazy dog";         int count = 0;         int greater = 0;         for (char character: ch)         {             map1.put(character, count);         }          for(Map.Entry&lt;Character,Integer&gt; entry : map1.entrySet() )         {             System.out.println("key is" + "\t" + entry.getKey() + "\t" + "Value is" + entry.getValue());         }          for(int i = 0; i &lt; s.length();i++)         {                Integer count1 = map1.get(s.charAt(i)); Line 28 ---&gt;            count1.intValue();             map1.put(s.charAt(i),new Integer (count1));               if(count1 &gt; greater)             {                 greater = count1;             }         }          if(map1.values().contains(1) &amp;&amp; greater == 1)         System.out.println("Pangram");         else if(map1.values().contains(0))         System.out.println("Not Pangram");         else if(greater &gt; 1)         System.out.println("Multiple Pangram" + "\t" + greater);      }     }   I am getting this error Exception in thread "main" java.lang.NullPointerException     at Pangram1.main(Pangram1.java:28)  I have tried all ways such that there wouldn't be autoboxing/Unboxing problems but still exception throws up.   Could someone please help me with it ?  Thanks !!
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?
Which is correct: "has died" or "died"? What tools and technologies are used to build the Stack Exchange Network?  See also: Does equality of characteristic polynomials guarantee equivalence of matrices? I have a qualifying exam coming up in a couple days and I am just trying to understand some pathological examples I have in my notes. I will list a similar problem which I know the solution to and then the question.  True or False:   let $A,B \in \mathbb{Q}^{n \times n }$  Suppose $xI-A$ and $xI-B$ are equivalent then $\det(xI-A) = \det(xI-B)$.     I wrote in my notes this is true because any two matrices are equivalent in $\mathbb{Q[x]}^{n \times n}$ if and only if they have the same invariant factors.  Since the characteristic polynomial is a product of the invariant factors it follows that $\det(xI-A) = \det(xI-B)$.        True or False:   let $A,B \in \mathbb{Q}^{n \times n }$. If $\det(xI-A) = \det(xI-B)$ (in $\mathbb{Q}[x]$) then $xI-A$ and $xI-B$ are equivalent  in $\mathbb{Q}[x]^{n \times n}$   I think this is false because of the fact that equality of determinants is not strong enough to guarantee all invariant factors are equal but I do not have an example. I've been try to download Xcode for work, but for some reason the Mac App Store is giving me a bit of trouble. Activity monitor shows some network usage, but in Launchpad it seems the download isn't moving.   When I go to the purchases panel of the Mac App Store, I see this.     No status, no pause button, in fact - the button has no text on it! I've tried restarting the App Store, restarting my computer, even removing the com.apple.appstore folder in /var/folders but alas, no luck.  Can anyone diagnose the issue? When I removed com.apple.appstore, Xcode still showed up on Launchpad, and clicking on it did nothing - it was frozen in time. So can I kill off this partial download and start new? In the Stack Overflow podcast #36 (), this opinion was expressed: Once you understand how easy it is to set up a state machine, you’ll never try to use a regular expression inappropriately ever again. I've done a bunch of searching.  I've found some academic papers and other complicated examples, but I'd like to find a simple example that would help me understand this process.  I use a lot of regular expressions, and I'd like to make sure I never use one &quot;inappropriately&quot; ever again. I have some questions about a suspended user's earning and activity.   Can suspended users get reputation back after the suspension period? If a user is suspended for 7 days and he/she earns reputation during this period. Then will it be calculated after completing suspension period? If a suspended user has awarded a bounty to other user and the awarded bounty marked as illegal. Then will that bounty rolled back to their account?  Can suspended users get any alert from comments or chat room using @username method? Can suspended users post comments on his/her question/answer? If another user replies or ask a question on suspended user's post. Then, can a suspended user give response back? Use the result of FPeval to color a table cell I am trying to give a table cell a grayscale color value based on it's numeric value. So far I have the following code  \documentclass{article} \usepackage{fp,xcolor,colortbl} \FPeval{\resb}{0.5}  \newcommand{\he}[1]{%     \FPeval{\resa}{2 * #1}%     \cellcolor[gray]{\resa}%     #1  }  \begin{document} \begin{tabular}{| c | c | c |}     \hline     \he{0.1} &amp; \he{0.2} &amp; \he{0.3} \\     \hline     \he{0.5} &amp; \he{0.8} &amp; \he{1.0} \\     \hline \end{tabular} \end{document}   The tables contain all floating point numbers. The error I get is :   Undefined control sequence. &lt;argument&gt; \resa    Is there a way I can use the result from the FPeval to color the cell? How can I create an empty file from the command line? When does a reaction happen if the trigger is movement? How to clear current “read-only” state on a USB flash drive I setup with Rufus? Three weeks ago I used  2.2 to install Windows 10 on my machine, and it has write-protected my flash drive. I’ve tried diskpart:  diskpart att disk clear readonly  clean create partition primary format fs=fat32 quick   And it kinda worked, it removed the image off the USB, but now it’s showing:  Current Read-only State : Yes Read-only  : No Boot Disk  : No Pagefile Disk  : No Hibernation File Disk  : No Crashdump Disk  : No Clustered Disk  : No   And I can’t format it or write on it.    The drive is a a Kingston DataTraveler G4 32GB model, without physical switches. How would I restore it back to normal (rw) state? How to check if PHP array is associative or sequential? PHP treats all arrays as associative, so there aren't any built in functions. Can anyone recommend a fairly efficient way to check if an array contains only numeric keys? Basically, I want to be able to differentiate between this: $sequentialArray = [     'apple', 'orange', 'tomato', 'carrot' ];  and this: $assocArray = [     'fruit1' =&gt; 'apple',     'fruit2' =&gt; 'orange',     'veg1' =&gt; 'tomato',     'veg2' =&gt; 'carrot' ]; the converse of Pythagoras Theorem Keeping an updated balance (Accounting) I have been struggling trying to find a way to properly and reliably maintain a balance for accounts in an order/payment system.  Currently, the process consists of three tables. Below example is very simplified but gets the point across.  Table one contains the account ID, name, total paid, total orders, balance etc.  Table two contains payments, date, the account ID (FK) and amount.  Table three contains orders, date, the account ID (FK) and amount.  Calculating the balance is of course as easy as  SELECT SUM(payments.AMOUNT) FROM payments WHERE ID = [account] SELECT SUM(orders.AMOUNT) FROM orders WHERE ID = [account]   Followed by some simple addition/subtraction math:  UPDATE accounts SET BALANCE = [balance] WHERE ID = [account]   All good - the problem is - how do I maintain this over let's assume years of activity and many, many transactions?  Currently the accounts table is updated every single time a transaction is made, meaning the above three statements run every time. There is of course an index on the ID column in all three tables, and everything is fast and neat for now, but I work with less than 100,000 transactions, meaning everything fits into the RAM and basically all I throw at the database gets executed immediately. Over time this will change, of course - so how do I handle this?  Is it better to mark the accounts as "dirty" and process balancing in a batch job later, or can I keep updating the balance real-time even when I reach the point where the orders and payments tables will not fit into the RAM?  Do I need to segment the orders and payments and "lock" everything before a given time, such as before last calculation? (I would rather not). I ask because then I could do a SUM WHERE DATE > [last lock timestamp] and update with UPDATE BALANCE = [balance] + [value for last lock] and prevent the problem from outgrowing resources.  I don't need a running balance for each transaction. That's all I can find results for when I try to research this problem. I just care about the total amount paid, the total amount ordered and the balance of accounts.  Why don't I calculate on the fly when I need the balance, you ask? Because one must be able to query the system and ask "Which of my (let's say) 50.000 accounts have a balance below 0?" - something we cannot do easily if we do not store the balance with every account. Add a Texture to an Object using Python and Blender 2.8 i have trouble to get a script working within Blender 2.8. The following function work perfectly for me in Blender 2.79, but not in 2.8.  def CreateMaterialFromImage(matName, imgPath):     '''Creates and returns a material from an Image'''     realpath = os.path.expanduser(imgPath)     try:         img = bpy.data.images.load(realpath)     except:         raise NameError("Cannot load image %s" % realpath)      # Create image texture from image     cTex = bpy.data.textures.new(matName, type='IMAGE')     cTex.image = img      # Create material     mat = bpy.data.materials.new(matName)      # Add texture slot for color texture     mtex = mat.texture_slots.add()     mtex.texture = cTex     mtex.texture_coords = 'UV'     mtex.use_map_color_diffuse = True     mtex.use_map_color_emission = True     mtex.emission_color_factor = 0.5     mtex.use_map_density = True     mtex.mapping = 'FLAT'     return mat   It seems to be that the material.texture_slots were removed.  Under following Link  i found the note:        Texture slots for materials, lamps and world were removed. They remain   for brushes, particles and freestyle linestyles.      So my question is where do i find this property now or how could i change my code to get things done?  Thanks for your help!  EDIT:  This seems to be an interesting link for people run in to issues by updating their scripts to 2.8. Unfortunately there is no solution for my problem listed, yet. While trying some problems along with my friends we had difficulty in this question.   True or False: The value of the infinite product $$\prod\limits_{n=2}^{\infty} \biggl(1-\frac{1}{n^{2}}\biggr)$$ is $1$.   I couldn't do it and my friend justified it by saying that since the terms in the product have values less than $1$, so the value of the product can never be $1$. I don't know whether this justification is correct or not. But i referred to Tom Apostol's Mathematical Analysis book and found a theorem which states, that    The infinite product $\prod(1-a_{n})$ converges if the series $\sum a_{n}$ converges.   This assures that the above product converges. Could anyone help me in finding out where it converges to? And,   Does there exist a function $f$ in $\mathbb{N}$ ( like $n^{2}$, $n^{3}$) such that $\displaystyle \prod\limits_{n=1}^{\infty} \Bigl(1-\frac{1}{f(n)}\Bigr)$ has the value $1$? Why do students go for a PhD even when chances of getting academic jobs on its completion are slim? This is in reference to my question: .  I was told in the answer of the above linked question that chances of landing a job as an assistant professor in Mathematics are quite slim. Very few people will actually get a permanent position in academia.  An article of 2014 shows only 0.5-3% of PhD graduates will actually get a job as an Assistant Professor.  But I have two questions:        Why do so many people still apply for a PhD in some reputed institutes in India even knowing the harsh reality? I found there are 1500 applications for four PhD scholarship positions.          One answer says that people move to industry, but I still don’t understand how after doing a PhD in suppose differential geometry or algebraic geometry one can do a job in industry if he/she gets no position as an assistant professor.   Will one be satisfied to do some managerial work in some Consultancy firm after doing a PhD in Mathematics?      Are people jobless after a PhD?   Completion of a PhD requires so much effort. So why is there no value after doing it?      NOTE:  In the most up-voted answer below it has been said that many who enroll for  a PhD don't even wish to pursue an academic career.  I have been asking my seniors who are currently pursuing a PhD or are in the verge of completing their degree or who have completed it. They said that they all want to be Professors in some Universities and want to be involved in research because that is the dream job for them.  I am obviously talking about PhD in Mathematics I have a TikZ picture with a node containing a minipage with an itemize environment; each item is a hyperref to other sections of the document.   When scaling the image (for example with \begin{tikzpicture}[scale=.7, transform shape] I've a strange behavior: links in itemize are not in the right place: they present a somewhat vertical offset, as if they don't scale as the rest of image.   Here the MWE:  \documentclass[a4paper]{article} \usepackage{tikz} \usepackage[pdftex]{hyperref} \begin{document}  Here something interesting\label{text:interesting-one} \newpage  Here something interesting, too\label{text:interesting-two} \newpage  and here there are very very interesting stuff\label{text:interesting-three} \newpage  \newpage Now the problem: links rectangles have some offset, making links unusable in case of long itemize  \begin{figure}[htb] \begin{tikzpicture}[scale=.7, transform shape] \node at (0,0) (mynode) { \begin{minipage}{4cm} \begin{itemize} \item \hyperref[text:interesting-one]{First link} \item \hyperref[text:interesting-two]{Second link} \item \hyperref[text:interesting-three]{Third link} \item \hyperref[text:interesting-one]{First link again} \item \hyperref[text:interesting-two]{Second link again} \item \hyperref[text:interesting-three]{Third link again} \end{itemize} \end{minipage} }; \end{tikzpicture} \end{figure} \end{document}   And here a snapshot of the problem    Note: This is evident using the default settings of hyperref package, which draws the red rectangle around links, but it took me some time to found it when only the text is coloured, i.e. when using \usepackage[linkcolor=blue,colorlinks=true]{hyperref} Loading multiple GPX files at once? I have a whole bunch of GPX files that I need to load into QGIS and loading them one at a time using the GPS plugin is a bit painful.  It will not allow one to select multiple files -- is there another way?  I did find this:  but I need to figure out a lot more about PostGIS and GDAL before trying that approach.  BTW I am using Mac version of QGIS -- just realised that this may be OS related What is in the space between a nucleus of an atom and its electrons? Cannot invoke method or retrieve property from null object. Object returned by the following call stack is null. \"File\r\n\"