I cannot figure out how to correctly initialize a button (button) I'm trying to create. The button stays null which in turn causes a NullPointerException on the line below it.  import android.content.Intent; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.Button; import android.widget.EditText;  public class SetCounter extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_set_counter);          //The code when the setButton is clicked.         //Todo 1: define the setButton and create its setOnClickListener. inside it past the following code:-           //On clicking the button the value of counterValueText should be sent to the MainActivity and it should be called.             final Button button = (Button) findViewById(R.id.countButton);             button.setOnClickListener(new View.OnClickListener() { //exception occurs on this line                 public void onClick(View v) {                     EditText counterValueText = (EditText) findViewById(R.id.counterValueText);                     int number = Integer.parseInt(counterValueText.getText().toString());                     Intent activityChangeIntent = new Intent(SetCounter.this, MainActivity.class);                      //Todo 2: use putExtra("Value",number); to pass values to the MainActivity.                     activityChangeIntent.putExtra("Value", number);                     startActivity(activityChangeIntent);                 }             });     }  }   the error occurs with the line   button.setOnClickListener(new View.OnClickListener() {   but I believe the error is actually in this line  final Button button = (Button) findViewById(R.id.countButton);   Finally, I have another class, MainActivity, in which I declare countButton which looks like this  final Button countButton = (Button) findViewById(R.id.countButton);   Added XML:  &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     tools:context="***.*****.******.lab11skeletontwo.SetCounter"&gt;      &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"         android:id="@+id/activity_adddoc"         android:layout_width="match_parent"         android:layout_height="match_parent"         tools:context="mishra.sripath.wecareforuclient.Adddoc"&gt;           &lt;Button             android:id="@+id/setButton"             android:layout_width="88dp"             android:layout_height="48dp"             android:layout_marginStart="140dp"             android:layout_marginLeft="140dp"             android:layout_marginTop="400dp"             android:text="Set" /&gt;          &lt;EditText             android:id="@+id/counterValueText"             android:layout_width="215dp"             android:layout_height="46dp"             android:ems="10"             android:inputType="number"             android:hint="Enter Value of Counter"             android:layout_marginStart="70dp"             android:layout_marginLeft="70dp"             android:layout_marginTop="230dp" /&gt;     &lt;/RelativeLayout&gt;  &lt;/android.support.design.widget.CoordinatorLayout&gt;
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 have gridded depth points in CSV format that I'm trying to add other map data to, in additional columns. I've tried joining fields, hoping that I could link the Shapefile data to the csv, but when I try to display the csv by graduated symbols based on the new fields, it goes blank. I used Nathan's tips from , but imported the csv as csv since I want to add map info to that, rather than adding csv info to a map.  See this picture below for the sea bottom temperature &amp; salinity voronois by month, underneath the csv points (a sample subset), with the joins already made. I added columns on the csv for each of the fields i'm intending to append.    I also tried spatial joins as per  however it says the layers aren't the same CRS (I checked, they are), then gets to 15% and hangs.  I also also tried spatial join through  but it hit a python error. I can try this again and look to debug the problem if this is the right way to go.  In short: appending polygon data as fields on a points-grid csv: what's the best way in QGIS 2.0? How to add desktop shortcut for URL, ignoring web app manifest? Goal:  Have a desktop shortcut that opens  , ignoring the contained web app manifest that otherwise "overrides" the saved shortcut to  and with "display": "standalone".  I had this working previously on an older Android phone before a replacement / upgrade.  Prior to the upgrade, I was able to long-press and open individual articles in new tabs - as well as copy link shortcuts to specific articles, as well as all of the other features and functionality that Chrome has to offer.  Here is just a partial selection of references of other users complaining about the same:       Using  provides a temporary successful work-around.  However, I can't find a successful way to add a link for this to my home screen.  The "Add to Home screen" option within Chrome instead saves a link to  - and in such a way that it opens as a web application instead of a web page within Chrome:       On a desktop operating system, this would be a non-issue.  (Create shortcut, enter desired URL, done.)  Attempt 1: Provide my own Manifest  So I created my own manifest - editing  to change the start_url attribute to https://news.google.com/news/i#0, and the display attribute from standalone to browser.  I then created my own HTML page that simply contained the below - then self-hosted both on a local web server:  &lt;html&gt;         &lt;head&gt;                 &lt;Title&gt;Google News&lt;/Title&gt;                 &lt;link rel="manifest" href="/news/manifest.json"/&gt;         &lt;/head&gt;         &lt;body&gt;                 Test         &lt;/body&gt; &lt;/html&gt;   However, this doesn't work:  Despite the shortcut being saved with the desired name and icon, it links back to my self-hosted HTML page, and not the indicated start_url.  Unfortunately, it appears that cross-domain URLs are not allowed per the manifest intent - as per  and  .  Attempt 1b: MITM website  Within the confines of my own local network, I figured I could try to  (MITM) the website to temporarily provide a desired manfiest to use for addition to the home screen.  Unfortunately, the website uses  here, which appropriately blocks the attempt.  Regardless - this is way too much work for what should be a simple effort.  Attempt 2: Widget Bookmark  Unfortunately, it looks like the 1x1 bookmark widget was removed in Chrome 48, as per  .  The suggested work-around is to use the "Add to Home screen" feature within Chrome.  Goto 10 / see beginning.  Attempt 3: Use the default-provided "Internet" browser  Unfortunately, using "Add shortcut on Home screen" in the default-provided "Internet" browser produces the same result as Chrome.  Consideration 4: Use a custom app / widget  Could probably write and install a custom application or widget that could be added to the home screen to meet the goal.  Or don't re-invent the wheel, and use an existing one.  Some possibilities:   "More Shortcuts":  "Shortcut Customizer":    Conclusion  How can someone create a desktop shortcut to an arbitrary URL, ignoring a provided web app manifest? How to disable phone number linking in Mobile Safari? What longest time ever was achieved at holding light in a closed volume? For what longest possible time it was possible to hold light in a closed volume with mirrored walls?   I would be most interested for results with empty volume but results with solid-state volume may be also interesting. Implement a Selective Comment Ban How do you beta test an iphone app? How can you beta test an iPhone app?  I can get it on my own device, and anyone that gives me a device, I can run it on theirs, but is there a way to do a limited release via the app store for beta testing?  Related: Also, see  on getting your app onto phones without using the App Store. What does a program do when it's sent SIGKILL signal? When I used killall -9 name to kill a program, the state become zombie. Some minutes later, it stopped really. So, what's happening during those minutes? Interfaces with static fields in java for sharing 'constants' I'm looking at some open source Java projects to get into Java and notice a lot of them have some sort of 'constants' interface.  For instance,  has an interface called , and most other core classes implement this interface. The interface is riddled with static members. Is there a reason for this approach, or is this considered bad practice? Why not use enums where it makes sense, or a static class?  I find it strange to use an interface to allow for some sort of pseudo 'global variables'.  public interface PConstants {    // LOTS OF static fields...    static public final int SHINE = 31;    // emissive (by default kept black)   static public final int ER = 32;   static public final int EG = 33;   static public final int EB = 34;    // has this vertex been lit yet   static public final int BEEN_LIT = 35;    static public final int VERTEX_FIELD_COUNT = 36;     // renderers known to processing.core    static final String P2D    = "processing.core.PGraphics2D";   static final String P3D    = "processing.core.PGraphics3D";   static final String JAVA2D = "processing.core.PGraphicsJava2D";   static final String OPENGL = "processing.opengl.PGraphicsOpenGL";   static final String PDF    = "processing.pdf.PGraphicsPDF";   static final String DXF    = "processing.dxf.RawDXF";     // platform IDs for PApplet.platform    static final int OTHER   = 0;   static final int WINDOWS = 1;   static final int MACOSX  = 2;   static final int LINUX   = 3;    static final String[] platformNames = {     "other", "windows", "macosx", "linux"   };    // and on and on  } Samba+Windows: Allow multiple connections by different users? I have a machine running Ubuntu with Samba that I use to share stuff with my family's Windows machines in our local network.  Currently they access a share for movies/music/etc with one user.  I want to connect them to another share as a different user (for example, user "goytacaz").  When I try connecting to this new share, Windows gives me "Error 1219" and complains about multiple connections by the same user.  How do I get my machine to accept multiple connections by the same user? Regex for numbers only I haven't used regular expressions at all, so I'm having difficulty troubleshooting. I want the regex to match only when the contained string is all numbers; but with the two examples below it is matching a string that contains all numbers plus an equals sign like "1234=4321". I'm sure there's a way to change this behavior, but as I said, I've never really done much with regular expressions.  string compare = "1234=4321"; Regex regex = new Regex(@"[\d]");  if (regex.IsMatch(compare)) {      //true }  regex = new Regex("[0-9]");  if (regex.IsMatch(compare)) {      //true }   In case it matters, I'm using C# and .NET2.0. How bug prioritization works in agile projects vs non agile When reporting a defect, we are setting the priority and severity of the defect. How this works with agile development? Is there any specific way ?  How bug prioritization works in agile projects vs non agile.?  Is there any other way of measuring the priority of a bug in agile projects? How can I install Steam? Look at this if block:  #!/bin/bash  str="m.m" if [[ "${str}" =~ "m\.m" ]]; then     echo "matched" else     echo "not matched"     exit 1 fi  exit 0   This should print "matched", but it doesn't. Where am I going wrong? Does ReLU layer work well for a shallow network? Why Did Anakin Skywalker Believe that Turning to the Dark Side of the Force Would Save Padmé? Just as the question asks: Why did Anakin come to believe that Padmé could be saved if he embraced the Dark side of the Force? Padmé clearly didn't believe it. Why was Anakin so driven to save Padmé through the dark side? Is a contradiction enough to prove a set equality to $\varnothing$? How much effect does the Bernoulli effect have on lift? I understand that the Bernoulli effect is a flawed explanation for the cause of lift, and does not cause much at all, but how much?   Is there any experimental data on the force caused by the Bernoulli effect? Maybe implicitly through data of the pressure difference between the top and underside of an aeroplane's wings. After that, I assume I could (crudely approximating the pressure to be acting perpendicularly to the flight direction) use $\Delta P A$ to work out the net force on the plane.    Perhaps there is another way to quantitatively analyse the extent to which the Bernoulli effect causes lift.  Edit: see  short cartoon (content similar to Mike Dunlavey's answer). Is there a service that I can use to check if my machine will be able to run a certain game? How can I clone an ArrayList and also clone its items in Java?  For example I have:  ArrayList&lt;Dog&gt; dogs = getDogs(); ArrayList&lt;Dog&gt; clonedList = ....something to do with dogs....   And I would expect that objects in clonedList are not the same as in dogs list. View linked Excel 'Windows' on separate screens