when run my app on android emulator its show unfortunately app stop message  import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView;  public class MainActivity extends AppCompatActivity implements View.OnClickListener{        Button blogin;       EditText etusername,etpassword;      TextView registerlink;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          etusername=(EditText) findViewById(R.id.uname);         etpassword=(EditText) findViewById(R.id.upassword);         blogin=(Button) findViewById(R.id.blogin);         registerlink=(TextView) findViewById(R.id.bregister);         blogin.setOnClickListener(this);         registerlink.setOnClickListener(this);     }      @Override     public void onClick(View v) {         switch(v.getId()){             case R.id.blogin:                  break;             case R.id.bregister:                 startActivity(new Intent(this,RegisterActivity.class));                 break;         }     } }   Xml coding for your reference. Logs shows a Nullpointer exceptions  &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:orientation="vertical"     android:layout_width="match_parent"     android:padding="10dp"     android:layout_height="match_parent"&gt;  &lt;EditText     android:id="@+id/uname"     android:layout_width="match_parent"     android:hint="@string/unamehint"     android:layout_marginBottom="10dp"     android:layout_height="wrap_content" /&gt;      &lt;EditText         android:id="@+id/upassword"         android:inputType="textPassword"         android:layout_width="match_parent"         android:hint="@string/upasswordhint"         android:layout_marginBottom="10dp"         android:layout_height="wrap_content" /&gt;     &lt;Button         android:id="@+id/blogin"         android:layout_gravity="center_horizontal"         android:layout_width="wrap_content"         android:layout_marginBottom="10dp"         android:text="@string/buttonname"         android:layout_height="wrap_content" /&gt;     &lt;TextView         android:id="@+id/register"         android:text="New User/Register"         android:textStyle="bold"         android:layout_gravity="center_horizontal"         android:layout_width="wrap_content"         android:layout_height="wrap_content" /&gt;  &lt;/LinearLayout&gt;   LOGCAT  254 9565-9565/com.example.prakash.aclientz E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.prakash.aclientz, PID: 9565 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.prakash.aclientz/com.example.prakash.aclientz.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.interna
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?
Java GUI repaint() problem? I have a JFrame. This JFrame contains a JButton. I click the JButton and 10 JTextFields are created.  the problem: I cannot see them until "I force a repaint()" by resizing the window. Only then do I see the JTextFields created.  CODE:  JPanel points = new JPanel();  //Creating the JTextFields: for (int i=0; i&lt;10; i++) {     JTextField textField = new JTextField();     points.add(textField); }  repaint(); this.repaint(); super.repaint(); points.repaint();     THANK YOU - after the for loop, I just called points.validate() and it worked... Group Membership Test for Permutations Ubuntu: Resize the root LVM(2?) partition Is there any difference in meaning between 'efficacy' and 'efficiency'? Let $x,y,z&gt;0$. Show that $$\sum_{cyc}(1-x)^2\ge \sum_{cyc}\dfrac{z^2(1-x^2)(1-y^2)}{(xy+z)^2}.$$ Here's what I have done. The expression $$\sum_{cyc}(1-x)\left((1-x)-\dfrac{z^2(1+x)(1-y^2)}{(xy+z)^2}\right)\ge 0$$ or $$\sum_{cyc}(1-x)\cdot\dfrac{x^2y^2+y^2z^2+xy^2z^2+2xyz-2xz^2-2x^2yz-x^3y^2}{(xy+z)^2}\ge 0.$$ But this way does not help for the starting inequality. How do I force Excel (and other Microsoft Office products) to stop opening files in the same application? Whenever I "double click" on an Excel file and another Excel file is open, the newly opened file automatically opens in the same application window as the previously opened Excel file. This isn't limited to just Excel, as I've seen Word do this as well. This poses a problem when wanting to compare documents side by side.    The current solution I have for this is to actually open another Excel or Word instance, and then open the file from within that application window itself. Is there a way to force Office to open a new instance of the application when double clicking on the file icons?  I'm currently using Office 2007 and Windows XP, but I've seen this on Office 2010 and Windows Vista and 7. I'm looking for an overall solution if possible. Why doesn't current pass through a resistance if there is another path without resistance? Why doesn't current pass through a resistance if there is another path without resistance? How does it know there is resistance on that path? Some clarification:  I understand that some current will flow through the resistance. A depiction of this phenomenon through Ohm's laws does not answer the 'why' part of the question as it does not illuminate the process behind this phenomenon. There seems to be disagreement among the answers on whether the charge repulsions are enough to cause this effect. Cited research would be appreciated to resolve this issue. To refine what I mean by this question, I think I should give an example of why I am curious as to the causal background of this phenomenon. If charge repulsions do in fact repel 'current' in the example of the short circuit, then why does the same phenomenon not happen in other parallel circuits. (Again, I know that not all circuits behave ideally) I believe the question is expressed in the most straightforward way possible. This should, however, not affect the scope of the answers. I do not wish to see or think on the level of an electron as circuit behavior always includes a cumulative effect due to the nature of electrostatic interactions. Assuming one wants to travel through China, what are the rules for visa-free access? To be more specific:   How does the 24-hour visa free transit work? How does the 72-hour version work? What does a person ineligible for either of these programs have to do to transit China? Do the programs apply to flights only or do they also work for transit on land? Would a visitor save much hassle by using visa free transit instead of just getting a visa?      NB: this is intended as a canonical question on transiting China $$\sqrt{x + \sqrt{x + \sqrt{x + \cdots}}}= 5$$ Replace non-numeric with empty string Quick add on requirement in our project.  A field in our DB to hold a phone number is set to only allow 10 characters.  So, if I get passed "(913)-444-5555" or anything else, is there a quick way to run a string through some kind of special replace function that I can pass it a set of characters to allow?  Regex? Word for a person being used I'm looking for a word to describe someone who is being used. I want a noun to describe this person, not a verb or or adjective.  Maybe like a pushover. Is the standard Canon 18-55 lens the same as 5 years ago? Do I need a transit visa to collect and re-check my luggage at Istanbul Ataturk airport? I'm Egyptian and flying to Cairo from Tbilisi, via Istanbul. The first flight Tbilisi-Istanbul is on Atlasjet, then from Istanbul to Cairo I am flying on Egyptair. For that, I have to recheck in at Istanbul to my Egyptair flight  Will I need to pass passport control at Istanbul airport to collect my bags and check in on Egyptair? Will I need a transit visa for that? Or it can be all done through neutral zone? How to create a scope? I'd like to create a custom scope that searches and returns results from an online source for personal use.  Is this possible? And if so, how? How do I get the path and name of the file that is currently executing? Prove that if $n \in \mathbb{N}$, then $$\sum_{d|n}{(d(n))^3}=(\sum_{d|n}{d(n)})^2$$ where $d(n)$ is the divisor function. I have know only information is $d(n)=\sum_{d|n}{1}$. Steps to Reproduce   Tap faster on the code. or Tap once on a huge code.   but happens only when  setupForGeneric() is called, might be a bug related to   private void setupForCode()   { String str = getIntent().getStringExtra("com.stackexchange.marvin:code_block"); PrettyWebView localPrettyWebView = (PrettyWebView)findViewById(R.id.code); localPrettyWebView.setPostBody("&lt;pre&gt;&lt;code&gt;" + TextUtils.htmlEncode(str) + "&lt;/pre&gt;&lt;/code&gt;", false); localPrettyWebView.setBackgroundColor("#eeeeee"); }  private void setupForGeneric() { String str = getIntent().getStringExtra("com.stackexchange.marvin:web_url"); PrettyWebView localPrettyWebView = (PrettyWebView)findViewById(R.id.code); localPrettyWebView.getSettings().setBuiltInZoomControls(true); localPrettyWebView.getSettings().setLoadWithOverviewMode(true); localPrettyWebView.getSettings().setUseWideViewPort(true); localPrettyWebView.loadUrl(str); localPrettyWebView.setBackgroundColor("#eeeeee"); }   Log  09-05 03:54:30.312: E/AndroidRuntime(26264): FATAL EXCEPTION: WebViewCoreThread  09-05 03:09:39.522: E/Crittercism(18318): java.lang.NullPointerException: [v0.1.22]  09-05 03:09:39.522: E/Crittercism(18318):   at android.content.ComponentName.&lt;init&gt;(ComponentName.java:75) 09-05 03:09:39.522: E/Crittercism(18318):   at android.content.Intent.&lt;init&gt;(Intent.java:3156) 09-05 03:09:39.522: E/Crittercism(18318):   at com.stackexchange.marvin.ui.ViewPopupActivity.showCode(ViewPopupActivity.java:25) 09-05 03:09:39.522: E/Crittercism(18318):   at com.stackexchange.marvin.ui.question.QuestionFragment$1.onCodeClicked(QuestionFragment.java:67) 09-05 03:09:39.522: E/Crittercism(18318):   at com.stackexchange.marvin.ui.common.PrettyWebView$WebAppInterface.codeClicked(PrettyWebView.java:197) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore.nativeTouchUp(Native Method) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore.nativeTouchUp(Native Method) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore.access$4000(WebViewCore.java:59) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1449) 09-05 03:09:39.522: E/Crittercism(18318):   at android.os.Handler.dispatchMessage(Handler.java:99) 09-05 03:09:39.522: E/Crittercism(18318):   at android.os.Looper.loop(Looper.java:137) 09-05 03:09:39.522: E/Crittercism(18318):   at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:790) 09-05 03:09:39.522: E/Crittercism(18318):   at java.lang.Thread.run(Thread.java:856) Is it correct to hyphenate with compound premodifiers? If so, where is the hyphen placed? How did humans and vulcans communicate in Star Trek: First Contact? How to effectively use the man pages? I am looking forward to mastering linux. I have been repeatedly told to refer to man pages when you are in doubt.   Though I am very comfortable with the commandline, I find it very difficult to quickly and efficiently use man to find help with commands. Hence I end up googling up how to get things done. It is even more painful when the system I am using does not have internet access and I have to walk back to my office to get help from the internet.  How does one master man pages? What are the most common tricks that can be used to quickly get whatever you want from the man page? What are the most commonly used keyboard shortcuts?