I am new to tries and testing how it works. Right now I am building a contact list. I add 'Prashanth' and 'Pradep' to the trie and when I search 'Pra' I should receive the count as two. My approach is having the variable size in each node and returning it when the string of same length is found. There are some unnecessary things/variables like payload etc which I used for debugging. The problem I found is when I store a character and a node in hashmap, empty node is getting stored. So I am getting 0 as answer all the time.    public class tries {  public static class Node {      HashMap&lt;Character, Node&gt; children = new HashMap&lt;&gt;();     boolean endOfWord = false;     int size =0;     int payload = 10;       public void setNode(char c, Node n) {       children.put(c,n);     }      public Node getNode(char c) {         return children.get(c);     }      public void addNode( String s,int index) {         Node current = children.get(s.charAt(index));         size++;         if(index ==s.length()-1)         {             endOfWord = true;             return;         }         if(current== null)          {              current.payload = 11;             this.setNode(s.charAt(index),current);         }         addNode(s,index+1);      }      public int findcount(String s, int index) {         Node current = children.get(s.charAt(index));          if(index ==s.length()-1)         {             current.endOfWord = true;             return current.size;         }         if(current == null)         {             return 0;         }           return findcount(s,index+1);     } } public static void main(String args[]) {     String c1 = "Prashanth";     String c2=  "Pradep";     Node n = new Node();     //tries t = new tries();      n.addNode(c1,0);     n.addNode(c2,0);      System.out.println(n.findcount("Pra",0));   }   }     Error which I get If i run this code. ( I will get 0 if I alter a bit)   Exception in thread "main" java.lang.NullPointerException at tries$Node.addNode(tries.java:35) at tries.main(tries.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
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?
Comment flags are broken If I flag a comment now, it puts the dialog off the page:        It is only fixed by performing one of these actions:   Maximize window (if not already maximized) Restore window (if maximized)         I am running Windows and Firefox; also I tried Firefox in safe mode. I would be interested to see what testing was done on this beforehand - as this seems like a pretty glaring error. Please and thank you.    Inspired by the answer, the following CSS worked for me. It makes me sad to have to fix Stack Exchange CSS; I would figure this community over all others would get it right. Oh well.  aside {   transform: none !important; } Php - regular expression to check if the string has chinese chars stl::multimap - how do i get groups of data? Multimap essentially has groups of data sorted by the key. I want a method by which I could access these individual groups and get their aggregate values. For example, in a std::multimap&lt; string, int &gt; I store   {"Group1", 1},  {"Group1", 2},  {"Group1", 3},   {"Group2", 10},  {"Group2", 11},  {"Group2", 12}   Having stored these values, I should be able to iterate this multimap and get the aggregate values of each "group". Problem is there aren't any functions defined in STL to access MultiMaps in such a way. I could use lower_bound, upper_bound to manually iterate the multimap and total the group's contents, but I am hoping there could be better ways already defined in STL ? Can anyone propose a solution as to how I could get the aggregate values for a group in the above example. Proof of Neumann Lemma Prove that if $\|A\| &lt; 1$, then $I-A$ is invertible. Here, $\|\cdot\|$ is a matrix norm induced by a vector norm.  This lemma is referred to as Neumann Lemma.  Any ideas on how to go ahead with this?  Thanks. How to use unnumbered chapters with KOMA-script? I am having some issues with the hyperref package. I would like to create a Introduction chapter without a number so I use \chapter*{Introduction} and \addcontentsline{toc}{chapter}{Introduction} because I want it in the table of contents (see example).  But then the link in my PDF viewer gets it wrong and also the automatically created header is no longer correct (see picture). The table of contents shows the right page number (p.1) but the link is also wrong.   What is my mistake here?  \documentclass{scrbook}  \usepackage{hyperref} \usepackage{blindtext} \usepackage{glossaries}   \makeglossaries  \newacronym{eg}{e.g.}{% for example }   \begin{document}   \frontmatter  % abstract before the table of contents \chapter*{Abstract} \addcontentsline{toc}{chapter}{Abstract} \blindtext  \tableofcontents  % chapter with acronyms \cleardoublepage \phantomsection  \printglossary[type=\acronymtype] \addcontentsline{toc}{chapter}{Glossary}  \cleardoublepage \mainmatter   \phantomsection % \chapter{Introduction} % with this everything is correct but I don't want the number \chapter*{Introduction} \addcontentsline{toc}{chapter}{Introduction}  \blindtext  \pagebreak  \blindtext  % first chapter \chapter{Chapter1}  \gls{eg} \blindtext  \pagebreak  \blindtext   \end{document} I want to do a survey of textbooks in set theory. Amazon returns 3582 books for the keywords "set theory". A small somewhat random selection with number of references in Google scholar is the following.   Two questions:    What textbooks in set-theory are considered standard?  What is a good place to aggregate standard references (of textbooks)?    (I'm only interested in text-books, which as a format already provide a kind of standardization)  Textbooks on set theory (author: title (year) #Google Scholar citations )   Thomas J. Jech: Set Theory 3rd Edition (1978) #2441  Kenneth Kunen: Set Theory (1980) #1881  P. R. Halmos: Naive Set Theory (1974) #1079 AA Fraenkel, Y Bar-Hillel, A Levy: Foundations of set theory (1973) #696 K Kuratowski, A Mostowski, M Mączyński: Set theory (1976) #609 Suppes: Axiomatic set theory  (1972) #589 Quine: Set theory and its logic (1969) #442 A Levy: Basic set theory (1979) #442 Herbert B. Enderton: Elements of Set Theory (1977) #349 Karel Hrbacek, Thomas J. Jech: Introduction to set theory (1999) #284 RR Stoll: Set theory and logic (1979) #281  N. Bourbaki: theory of sets (1970) #211 K Devlin: The joy of sets: fundamentals of contemporary set theory (1994) #182 Ciesielski: Set theory for the working mathematician (1997) #156 YN Moschovakis: Notes on set theory (1994) #138 FW Lawvere: Sets for mathematics (2003) #118 G Takeuti, WM Zaring: Introduction to axiomatic set theory (1982) #106 Kaplansky: Set Theory and Metric Spaces (2001) #103 Potter: Set Theory and Its Philosophy: A Critical Introduction (2004) #91 PT Johnstone: Notes on logic and set theory (1987) #87 Judith Roitman: Introduction to Modern Set Theory (1990) #47 Derek Goldrei: Set Theory: For Guided Independent Study (1996) #31 Basic set theory: A Shen, NK Vereshchagin (2002) #14 Ralf Schindler: Set Theory (2014) #13 Foreman, Kanamori: Handbook of Set Theory (2009) #38   Note:  Please feel free to add textbooks to the list, as long as they are not just on a smaller subset of set theory. (Some of the dates might not be the first published edition.) Smallest positive element of $ \{ax + by: x,y \in \mathbb{Z}\}$ is $\gcd(a,b)$ Let $S = \{ax + by: x,y \in \mathbb{Z}\}$  and let $e &gt; 0$ be the smallest element in $S$. Prove that $e \mid a$, and hence prove that $e = \gcd(a,b)$  I'm afraid I can't provide much of my initial working here because I'm at a loss of how to start.  I suppose that to show $e\mid a$ I would have to show that $eg = a$ for some $g \in \mathbb{Z}$. But I have no idea how I would do this. Computing second partial derivative with polar coordinates Consider the polar coordinates with $x=r\cos\theta$ and $y=r\sin\theta$.  I can show using the chain rule that $$\frac{\partial}{\partial x} = \frac{x}{r} \frac{\partial}{\partial r} -\frac{y}{r^2} \frac{\partial}{\partial \theta}$$   What is the method to compute $\dfrac{\partial^2}{\partial x^2}$? I don't know how to do it. Will Canadian citizens be denied entry to Canada during COVID-19 border closure? I am using an old laptop and doing heavy processing that needs high CPU usage for a long time (~30mins - 2hours). When the process puts heavy load on CPU for a long time, CPU overheats and computer shuts down. I don't want to use a cooler/stand because I am carrying this laptop around and working outside home.  Is there a way/application that I can limit CPU usage of a process in Windows?  Note: Setting the priority of the process from task manager does not work.  Note 2: Fans are clean. I tried control+shift+power button as well as command+shift+power button. Neither seem to work. I have made a raster elevation map of Greenland, and have information of the region, cities and more as vectors. The information is not in the same place as my elevation map.  I have selected EPSG:5938 on the bottom right in QGIS and on my informations and elevation map I have set the CRS to the same like the picture    How do I get it all on the same position? Syntax error while creating DB2 Trigger What is wrong in the below trigger syntax, I am getting this error An unexpected token "INT" was found following " DECLARE NULL_ROW_ID".  Expected tokens may include:  "END-OF-STATEMENT".. SQLCODE=-104, SQLSTATE=42601, DRIVER=3.68.61  CREATE TABLE A (     A_ID INT NOT NUll,     A_CODE VARCHAR(100) NOT NULL,     PRIMARY KEY(A_ID) );  CREATE TABLE B (     B_ID INT NOT NUll,     B_CODE VARCHAR(100) NOT NULL,     A_ID INT,     PRIMARY KEY (B_ID),     FOREIGN KEY (A_ID) REFERENCES A (A_ID)  );  CREATE OR REPLACE TRIGGER B_TRIGGER AFTER UPDATE OF A_ID ON B REFERENCING NEW AS N OLD AS O FOR EACH ROW     WHEN (N.A_ID IS NULL)     BEGIN ATOMIC         DECLARE NULL_ROW_ID INT;         SET NULL_ROW_ID = (SELECT A_ID FROM A WHERE A_CODE = 'Custom Null String');         IF NULL_ROW_ID IS NULL THEN             SIGNAL SQLSTATE '70000' SET MESSAGE_TEXT = 'Custom Null String row not found.';         END IF;     SET N.A_ID = NULL_ROW_ID;     END @   It's on DB2 Express-C 10.5 Why isn't sizeof for a struct equal to the sum of sizeof of each member? Why does the sizeof operator return a size larger for a structure than the total sizes of the structure's members? How to deal with SettingWithCopyWarning in Pandas Unexpected workspace change? My friend who has only recently downloaded blender has come across a workspace issue. He said he accidentally pressed a button and it has entirely changed his user interface/ Workspace. He can't open, save or do anything with the change.    This is a full window image! At what age is the Force detectable in children? Why can't two series-connected diodes act as a BJT? Another form of the question is: will joining two diodes with wires (pn-np) make a transistor-equivalent?  I read that they are not equivalent, but why? Changing Date format and appending to original file I have file like this called a.txt:  [2016-03-30T04:51:51.599-04:00]!ER_DEV!Port_Conflict!/u05/app/ [2016-01-20T04:30:21.885-04:00]!ER_DEV!Port_Conflict!/u05/app/   I need to modify it so it looks like:    2016-03-30 04:51:51!ER_DEV!Port_Conflict!/u05/app/   2016-01-20 04:30:21!ER_DEV!Port_Conflict!/u05/app/   i already wrote a command to change [2016-03-30T04:51:51.599-04:00] to 2016-03-30 04:51:51 .but how to append the query output to original file.    awk -F'!' '{print $1}' a.txt | awk -F '[T.]' '{print $1 " " $2}' | awk '{gsub(/\[/,"")}1' Show that $n^3-n$ is divisible by $6$ using induction As homework, I have to prove that     $\forall n \in \mathbb{N}: n^3-n$ is divisible by 6   I used induction  1) basis: $A(0): 0^3-0 = 6x$ , $x \in \mathbb{N}_0$ // the 6x states that the result is a multiple of 6, right?  2) requirement: $A(n):n^3-n=6x$  3) statement: $A(n+1): (n+1)^3-(n+1)=6x$  4) step: $n^3-n+(n+1)^3-n=6x+(n+1)^3-n$  So when I resolve that I do get the equation: $n^3-n=6x$ so the statement is true for $\forall n \in \mathbb{N}$  Did I do something wrong or is it that simple?