Whenever i run the app, enter the name and press the submit button the app crashes.Here's the code   public class MainActivity extends AppCompatActivity {  int x, sum=0;  String str,str2;  @Override  protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_main);     Toolbar toolbar = findViewById(R.id.toolbar);     setSupportActionBar(toolbar);      final Button chk = findViewById(R.id.check);     final Button sub = findViewById(R.id.submit);     final EditText name = findViewById(R.id.name);     chk.setEnabled(false);      sub.setOnClickListener(             new View.OnClickListener() {                 public void onClick(View view) {                     x = str.length();                     str = name.getText().toString();                     if (x &gt;= 4 &amp;&amp; x &lt;= 10)                         chk.setEnabled(true);                 }             });   And here's the xml code for the submit button       &lt;Button      android:id="@+id/submit"      style="@style/Widget.AppCompat.Button.Colored"      android:layout_width="wrap_content"      android:layout_height="wrap_content"      android:layout_marginBottom="8dp"      android:layout_marginEnd="8dp"      android:layout_marginStart="8dp"      android:layout_marginTop="8dp"      android:text="@string/submit"      app:layout_constraintBottom_toBottomOf="parent"      app:layout_constraintEnd_toEndOf="parent"      app:layout_constraintStart_toStartOf="parent"      app:layout_constraintTop_toTopOf="parent" /&gt;   I'm a beginner and it's my first app so please excuse me if you find it a naïve question. The following is the logcat message:  12-11 22:55:20.678 4277-4277/com.example.shantanu.namerank D/AndroidRuntime: Shutting down VM  12-11 22:55:20.702 4277-4277/com.example.shantanu.namerank E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.shanu.namerank, PID: 4277 java.lang.NullPointerException: Attempt to invoke virtual method 'int'java.lang.String.length()' on a null object reference  at com.example.shanu.namerank.MainActivity$1.onClick(MainActivity.java:32)  at android.view.View.performClick(View.java:5610)  at android.view.View$PerformClick.run(View.java:22265)  at android.os.Handler.handleCallback(Handler.java:751)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6077)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
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?
How many people have undergone carbon freezing in Star Wars? We all know the story of Han Solo being a guinea pig for the planned freezing of Luke Skywalker, but how often are people "stored" in this way? How can we prove that $N_G(H)=H$ implies $N_{f(G)}(f(H))=f(H)$ How do you use a gray card? There are already   on how to make a gray card, but unfortunately my ignorance goes deeper than that.  How do you use a gray card? When should unions be used? Why do we need them? If I create just a basic hello.tex file an compile it using   pdflatex hello.tex   The pdflatex program is creating a plethora of file which is a little annoying. Currently it writes all those files about which I really don't care:  hello.aux, hello.log, hello.nav, hello.out, hello.snm, hello.toc   Is there a way to tell pdflatex to only write hello.pdf if the build is successful ? If not, can I specify the output directory of those files ? Maybe I could just write them in /tmp. Let $\mathbb R$ denote the set of all real numbers. Find all function $f: R\to \ R$ such that   $$f\left(x^2+f(y)\right)=y+(f(x))^2$$   It is the problem. I tried to it by putting many at the place of $x$ and $y$ but I can't proceed. Please somebody help me. Page layout assignments with XML metadata API How do I define page layout assignments for different record types via metadata XML files? Is it possible to assign the same value to multiple keys in a dict object at once? What is the norm of this bounded linear functional? Let $a$, $b$ be two arbitrary but fixed real numbers such that $a &lt; b$, let $C[a,b]$ denote the normed space of all continuous real (or complex) valued functions defined on $[a,b]$ with the maximum norm, and let $f$ be the functional defined on $C[a,b]$ as $$f(x):= \int_{a}^{b} x(t) x_0(t) dt $$ for all $x$ in $C[a,b]$, where $x_0$ is a fixed element of $C[a,b]$.   Now $f$ is evidently linear and bounded. How to compute the norm of $f$? What is this norm?   And what is the norm of the bounded linear functional $g$ defined as follows: $$g(x):= \int_{a}^{(a+b)/2} x(t) \cdot dt - \int_{(a+b)/2}^{b} x(t) \cdot dt$$ for all $x$ in $C[a,b]$? Which one is the formula of angular velocity? Is it $\omega= vr$? If not then why does the source below use $mvr=nh/2\pi$, where $mvr$ is angular momentum and $vr$ is angular velocity? Again $\omega=v/r$ shows radian per second. I saw $\omega= vr$ in one book and $\omega= v/r$ in another! How to make wget faster or multithreading? I've just upgraded my computer hardware(cpu + motherboard + graphic card + memory + hard disk), so that install a new OS is needed. I tried to download debian-6.0.6-amd64-netinst.iso with wget command but the speed is so slow that I could not bear. 4Kb/s ~ 17 Kb/s, slow like a running turtle, or even more slower if I use Chrome.  I've read the help information of wget, it seems like there are no options could make it more faster.  Is there anyway to make wget faster? Or is it possible to make it multi-threading download?  PS: my bandwidth is 4M. I use this command:  wget -c url  http://hammurabi.acc.umu.se/debian-cd/6.0.6/amd64/iso-cd/debian-6.0.6-amd64-netinst.iso how to sort by the day of the week? I have two files.  file1:  Dave 734.838.9800   Bob 313.123.4567   Carol 248.344.5576   Mary 313.449.1390   Ted 248.496.2204   Alice 616.556.4458      file2:  Bob Tuesday   Carol Monday   Ted Sunday    Alice Wednesday   Dave Thursday     Mary Saturday     I merged the two files.  file3 should look like this:  Name      On-Call     Phone   Carol     MONDAY      248.344.5576   Bob       TUESDAY     313.123.4567   Alice     WEDNESDAY   616.556.4458   Dave      THURSDAY    734.838.9800   Nobody    FRIDAY      634.296.3356   Mary      SATURDAY    313.449.1390   Ted       SUNDAY      248.496.2204     But I cannot get the weekdays to be in order. How do I go about doing that? SharePoint 2013 Jan 2016 Updates Is anyone here experience problems in SharePoint after installing the latest JAN 2016 on 13th Jan 2016 (Western Australian Time) updates for SharePoint 2013. I am guessing it could be KB3114503 update giving me problems.  I am getting the same problem on other machines after running the same updates too.  The problem I am receiving is, on every list view I get this error message below:  TypeError: Unable to get property 'replace' of undefined or null reference   TypeError: Unable to get property 'replace' of undefined or null referenceSys.ArgumentNullException: Sys.ArgumentNullException: Value cannot be null. Parameter name: element Foolproof way to ensure Google news pulls the correct image for its thumbnails? Google news results have an acompanying thumbnail next to articles that show up in the results.    If Google's crawler can't find a thumbnail to pull from our site, it uses its next best guess from another site, therefore linking the image to another site but still uses our headline.  Example:  Headline from Reuters, Image from Livemint:   Our pages absolutely have images, they are not massive in file-size or dimensions, yet we are not having them pulled / crawled correctly.  We have read up on the suggestions from Google, and from others around the web and nothing is panning out.  Has anyone had any experience where they can ensure Google news will pull a thumbnail of our choosing? How do I count the number of occurrences of a char in a String? How can I run a specific command for each find result? How would one run a specific command for each file that was found by using the find command? For the purpose of the question lets say that I would simply like to delete each file found by find. Can I find out which tags I have created? This would be interesting to know.  The tags could be highlighted on the users page for example. Is there a place on the internet where I could find actual Star Trek episode scripts? Through the years I have purchased a few Star Trek scripts. I even have a DS9 script a buddy of mine mistakenly took off set and dazzled me with at Christmas years ago. As neat as those are to own, they are impossible to search. Is there a place on the internet where the Star Trek show or movie scripts can be obtained in digital format?  (Sometimes I remember a quote and would love to find it. From time to time the internet delivers. Occasionally it does not. I want to have a resource to find quotes as I think of them.) I want to derive a closed formula for the integral $$I_n= \int \frac {dx}{\prod_{r=0}^n (x+r)}$$  On writing out first few terms we get   For $n=0$, $$I_0=\ln \vert x\vert+C$$ For $n=1$, $$I_1=\ln \vert x\vert-\ln \vert x+1\vert+C$$ For $n=2$ $$I_2=\frac {1}{2!}\left(\sum_{r=0}^2 (-1)^r\binom {2}{r} \ln \vert x+r\vert\right)+C$$ For $n=3$ $$I_3=\frac {1}{3!}\left(\sum_{r=0}^3 (-1)^r\binom {3}{r} \ln \vert x+r\vert\right)+C$$  Hence for generalized $n$ we have $$I_n=\frac {1}{n!}\left(\sum_{r=0}^n (-1)^r\binom {n}{r} (\ln \vert x+r\vert)\right)+C$$  Now this is just an observation but I want to prove that it is correct. I have tried lot of methods but not useful. Partial fractions would have been most useful but would go out on tedious task which is nearly impossible.  Also integration by parts won't help nor any trig substitution. So any ideas are welcome.  And ya,  this is not a homework question,  it's a question which I just saw in a integral challenge paper. I'm trying to access an XML file within a jar file, from a separate jar that's running as a desktop application.  I can get the URL to the file I need, but when I pass that to a FileReader (as a String) I get a FileNotFoundException saying "The file name, directory name, or volume label syntax is incorrect."  As a point of reference, I have no trouble reading image resources from the same jar, passing the URL to an ImageIcon constructor.  This seems to indicate that the method I'm using to get the URL is correct.  URL url = getClass().getResource("/xxx/xxx/xxx/services.xml"); ServicesLoader jsl = new ServicesLoader( url.toString() );   Inside the ServicesLoader class I have   XMLReader xr = XMLReaderFactory.createXMLReader(); xr.setContentHandler( this ); xr.setErrorHandler( this ); xr.parse( new InputSource( new FileReader( filename )));   What's wrong with using this technique to read the XML file?