I want to show the data in ListView using array adapter. When I run the program I got the NullPointerException. error was in myarray.add(contactid+ " - ");  full Error was:     java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.util.ArrayList.add(java.lang.Object)' on a null object reference at com.android.jsonparsingtest2.MainActivity$JSONTask.doInBackground(MainActivity.java:82)                                                                                   at com.android.jsonparsingtest2.MainActivity$JSONTask.doInBackground(MainActivity.java:44)   MainActivity.java  public class MainActivity extends ActionBarActivity {  private ListView tvData;  private ArrayAdapter arrayAdapter;  @Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_main);     Button btnHit = (Button) findViewById(R.id.btnHit);      btnHit.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View v) {             new JSONTask().execute("http://a.nextput.com/offers/19/o/a0f252064bd27339607c7166d270d82a/f?aff_id=56556_18&amp;im=25");         }     }); }  public class JSONTask extends AsyncTask&lt;String, String, ArrayList&lt;String&gt;&gt; {     ArrayList&lt;String&gt; myarray;     @Override     protected void onPreExecute() {         super.onPreExecute();     }      @Override     protected ArrayList&lt;String&gt; doInBackground(String... params) {         HttpURLConnection connection = null;         BufferedReader reader = null;         try {             URL url = new URL(params[0]);             connection = (HttpURLConnection) url.openConnection();             connection.connect();              InputStream stream = connection.getInputStream();             reader = new BufferedReader(new InputStreamReader(stream));             StringBuffer buffer = new StringBuffer();              String line = "";             while ((line = reader.readLine()) != null) {                 buffer.append(line);             }              String finalJson = buffer.toString();             JSONObject parentObject = new JSONObject(finalJson);             JSONArray parentArray = parentObject.getJSONArray("offers");              //ArrayList&lt;String&gt; data = new ArrayList&lt;&gt;();             StringBuffer finalBufferData = new StringBuffer();             for (int i = 0; i &lt; parentArray.length(); i++) {                 JSONObject finalObject = parentArray.getJSONObject(i);                 String contactid = finalObject.getString("app_name");                 //String custname = finalObject.getString("name");                 //String custemail = finalObject.getString("email");                 //String custgender = finalObject.getString("gender");                 //String mobileno = finalObject.getString("mobile");                 myarray.add(contactid+ " - ");             }             return myarray;          } catch (MalformedURLException e) {             e.printStackTrace();         } catch (IOException e) {             e.printStackTrace();         } catch (JSONException e) {             e.printStackTrace();         } finally {             if (connection != null) {                 connection.disconnect();             }             try {                 if (reader != null) {                     reader.close();                 }             } catch (IOException e) {                 e.printStackTrace();             }         }         return null;     }      @Override     protected void onPostExecute(ArrayList&lt;String&gt; result) {         super.onPostExecute(result);         // tvData.setText(result);         arrayAdapter = new ArrayAdapter(MainActivity.this, android.R.layout.simple_list_item_1, result);         tvData = (ListView) findViewById(R.id.tvJsonItem);         tvData.setAdapter(arrayAdapter);     } }  }
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?
\sqrt[x]{y} Breaks With unicode-math 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? Using more than one set of Locators in a Manipulate In fact, of these, only Charcoal shows a recent time stamp. Is there a gender-neutral pronoun that can replace “his” or “her”? I've got a huge list of date-times like this as strings:  Jun 1 2005  1:33PM Aug 28 1999 12:00AM   I'm going to be shoving these back into proper datetime fields in a database so I need to magic them into real datetime objects.   This is going through Django's ORM so I can't use SQL to do the conversion on insert. The strange thing about the maximum in Planck's law Why is "can I get" replacing "could I have"? I noticed the other day when serving the public that when asking for something, people were saying "Can I get an xyz, please". The previous time I had such a job it was "Could I have an xyz", or "May I have..." if they were being very polite.  Does anyone know when this trend started and what caused it? What is postselection in quantum computing? A quantum computer can efficiently solve problems lying in the complexity class . I have seen a claim the one can (potentially, because we don't know whether BQP is a proper subset or equal to PP) increase the efficiency of a quantum computer by applying postselection and that the class of efficiently solvable problems becomes now postBQP = .  What does postselection mean here? Show that a ring is commutative if it has the property that ab = ca implies b = c when $a\neq 0$ Show that a ring is commutative if it has the property that ab = ca implies b = c when $a\neq 0$.   This is my proof to show that a ring is commutative if it has the property that ab = ca implies b = c.  We need to show that if x, y ∈ R then xy = yx. Let a = x, b = yx and c = xy. Then ab = x(yx) = (xy)x = ca. Thus, by the hypothesis, b = c, or xy = yx. Thus, for x, y ∈ R we have xy = yx.   How would I show when $a\neq 0$? Disabling SSLv3 but still supporting SSLv2Hello in Apache Many SSL clients, notably JDK 6, use the SSLv2Hello protocol to handshake with the server.  Using this protocol does not mean you are using SSL 2.0 or 3.0 for that matter; it is merely a handshake to determine which protocol to use.  [  However, in Apache, if you disable SSLv3 support, this apparently removes support for the SSLv2Hello protocol.  Apache Tomcat has explicit support for SSLv2Hello; that is, you can enable that, but not enable SSLv3.    Is there any way to do this in Apache?    [Update]   This is my protocol config:    SSLProtocol +TLSv1 +TLSv1.1 +TLSv1.2 -SSLv3 Got a working screen via HDMI, but the DVI won't go past 1360x768 (a PackardBell Maestro monitor). Had no issues in Windows 7.  I've tried all the xrandr tricks, see the output below:   xrandr  Screen 0: minimum 8 x 8, current 3280 x 1080, maximum 16384 x 16384 VGA-0 disconnected (normal left inverted right x axis y axis) DVI-D-0 disconnected (normal left inverted right x axis y axis) HDMI-0 connected primary 1920x1080+1360+0 (normal left inverted right x axis y axis) 510mm x 287mm    1920x1080      60.0*+   59.9     50.0      1680x1050      60.0      1600x900       60.0      1440x900       59.9      1280x1024      75.0     60.0      1280x800       59.8      1280x720       60.0     59.9     50.0      1152x864       75.0      1024x768       75.0     70.1     60.0      800x600        75.0     72.2     60.3     56.2      720x576        50.0      720x480        59.9      640x480        75.0     72.8     59.9   DVI-D-1 connected 1360x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm    1024x768       60.0 +    1360x768       60.0*    59.8      1152x864       60.0      800x600        72.2     60.3     56.2      680x384        60.0     59.8      640x480        59.9      512x384        60.0      400x300        72.2      320x240        60.1     cvt 1920 1080 # 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz Modeline "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync  xrandr --newmode "test" 173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync  xrandr --addmode DVI-D-1 test X Error of failed request:  BadMatch (invalid parameter attributes)   Major opcode of failed request:  140 (RANDR)   Minor opcode of failed request:  18 (RRAddOutputMode)   Serial number of failed request:  37   Current serial number in output stream:  38    I'm using the latest driver from Nvidia (binary, 352.63) because Nouveau would show a black screen on my second monitor.  I got stuck on manually finding/creating a xorg.conf file and adding some monitor hacks, can anyone help me? In single-blind peer-review, can you reveal your identity without the editor's consent? In my field (chemistry), review is always done in a single blind process, i.e. the author does not know who the referees were, but the referees do know who the authors are. In ten years, I have never seen a referee breaching this anonymity, e.g. by signing their review, unless they got prior approval by the editor (in order to continue discuss things further with the authors, once the manuscript was accepted for publication).  So, it seemed logical to assume that in single blind peer-review, the reviewer should not disclose his identity without the editor's consent. Yet, some people have told me ( and ; also IRL a friend from human sciences) that they have seen people sign their reviews, or write emails to them after the review but before the paper is published.  So, in single-blind peer-review, can you reveal your identity without the editor's consent? Does it depends on the customs of each field, or is there a hard rule? (in which case, the few anecdotes I heard were outliers) Is every dense subspace of a separable space separable? I was having trouble playing the game on my android so I downloaded it to my wife's phone (Galaxy S6). I read some posts on how to get it running on my android and it worked but, my level 7 account is on my wife's phone.  How do I get it back to my android? When I sign out and back in it doesn't ask for any sign in info. I've tried deleting the app's data and even uninstalling and re-installing, but it still doesn't ask for sign-in info. The search parameter isanswered ignores acceptances I'm considering taking a loan on my 401k in order to pay off and close 2 credit cards.  I have approximately 30 years until I consider retiring.  The amount of the loan will be $1700 which is less then 20% of my current 401k balance.  I will continue to put 9% of my paycheck into a Roth 401k, and my employer matches 9%.  The loan will be paid back at 3.25% (to myself) and does have $183 in fees.  There are 2 cards I will pay off and close if I follow through with this plan.  One card is 17.9% interest with roughly a $650 balance.  The other is 23% (ish) with roughly a $1,025 balance.  Both of these cards do have an annual fee associated with them, I used them to rebuild my credit and have a newer, lower interest, no fee card that I will keep active for emergencies.  Would it be advantageous for me to pay off these two credit cards and cancel them with a 401k loan? Find all polynomials $P:\mathbb{C}\rightarrow\mathbb{C}$ such that $$P(x^2)=P(x)^2 .$$   Here is what I tried:  First, it is easy to see the constant solutions, namely $P\equiv 0,P\equiv 1$.  Let $r$ be a root of $P$ (i.e. $P(r)=0$). It follows that all terms in the infinite sequence $r,r^2,r^4,\dots,r^{2n},\dots$ are roots of $P$. To avoid a polynomial with infinite roots, we have to have the sequence be periodic. So it turns out that either $r=0$, or the roots of $P$ are roots of unity of degree $2n$ for some $n\in\mathbb{N}$.  In the first case, we get $P(x)=xQ(x)$. Plugging in, we get $$x^2Q(x^2)=x^2Q(x)^2\implies Q(x^2)=Q(x)^2 ,$$ i.e. that $Q$ satisfies the same condition as $P$.  In the second case, we have $P(x)=(x^{2n}-1)Q(x)$. Plugging in, we get $(x^{2n}-1)Q(x^2)=(x^{2n}-2x^n+1)Q(x)^2$. I was not sure how to proceed from here. Must an ideal contain the kernel for its image to be an ideal? Do I need a transit visa for a layover in the United Arab Emirates? Do I need a transit visa for a layover via airports in the UAE, such as Dubai International Airport or Abu Dhabi International Airport? If so, what are the requirements for such a visa? Can I get the transit visa on arrival?