I tried to set views to Enabled(false), but it keeps giving me this error:  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setEnabled(boolean)' on a null object reference   Something I don't understand is that the error didn't occur at ccl_stage11[][] but occured at vtl_stage11 and hrl_stage11[][] even though they're using same for in the same way.  I tried to unroll the 'for' loop at the setEnabled part, but it didn't work.  Can anyone help me to solve this problem? Here is the code related to this error.  public class Stage1Activity1 extends AppCompatActivity {      Button[][] ccl_stage11 = new Button[4][4];     Button[][] hrl_stage11 = new Button[4][4];     Button[][] vtl_stage11 = new Button[4][4];        @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_stage11);           buttonSettings(); }  protected void buttonSettings() {           int k = 0;         for (int i = 1; i &lt;= 3; i++) {             for (int j = 1; j &lt;= 3; j++) {                 ccl_stage11[i][j] = findViewById(R.id.ccl_stage11_11 + k);                 ccl_stage11[i][j].setEnabled(false);                 k++;             }         }         for (int i = 0; i &lt;= 3; i++) {             for (int j = 0; j &lt;= 3; j++) {                 vtl_stage11[i][j] = findViewById(R.id.vtl_stage11_00 + k);                 hrl_stage11[i][j] = findViewById(R.id.hrl_stage11_00 + k);                 k++;             }         }         for(int i=0;i&lt;=3;i++){             for (int j =0;j&lt;=3;j++){                 vtl_stage11[i][j].setEnabled(false);                 hrl_stage11[i][j].setEnabled(false);             }         }         ccl_stage11[1][3].setEnabled(true);         ccl_stage11[3][1].setEnabled(true);       }   The error occurs at   for(int i=0;i&lt;=3;i++){     for (int j =0;j&lt;=3;j++){         vtl_stage11[i][j].setEnabled(false);         hrl_stage11[i][j].setEnabled(false);     } }
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 to relate areas of circle, square, rectangle and triangle if they have same perimeter?? I was given a question which was like:     Suppose that a circle, square, rectangle and triangle have same perimeter. How area their areas related??   My work:  I broke the question in parts and tried to prove it seperately:  STEP $1$. Suppose the given perimeter is $P$.So the radius of circle will be ${r=P/2\pi}$.  And hence area of the circle will be:   ${P^2/4\pi}$.  Side of square will be $P/4$ and hence area of square will be $P^2/16$.   It is obvious that ${P^2/4\pi}$  >  $P^2/16$.   So Area of circle is more than area of square.  STEP $2$: Whether by using $AM&gt;GM$ inequality or by using a bit of differentiation, we can get that product off two quantities is maximum when they are equal.  So, Area of square is more than Area of rectangle.  Here, the hardest part come (at least for me). I can't relate the area of triangle to any of Circle, Square or Rectangle. It would have been easy if the triangle was Equilateral, Right angle but the question is talking about a general triangle.  However, when I considered the situation with different examples (Assuming the perimeter and calculating the area, I got the relation:  Circle > Square > Rectangle > Triangle.  I shall be highly thankful if you guys can establish the relation in purely mathematical way.  EDIT: This question does not ask that whether circle have the largest area among all 2-D figures or not. The OP just want to relate the areas of Circle, Square, Rectangle, Triangle in a pure mathematical way. Automatically redirect anonymous user from unanswered duplicate question to corresponding answered version Duplicate questions that use different words to describe the same problem are important for people to find the content via search engines. But the user experience when an anonymous user arrives at a duplicate is less than ideal.  They have to notice the duplicate link and understand that the answer they are looking for is likely behind that link. I don't think this is all that obvious to someone without experience with an SE site.  I propose to just redirect users to the duplicate automatically if the closed duplicate has zero answers. In that case they need to follow the link to the duplicate in any case, so we might as well redirect them to it in the first place.  I could imagine this being problematic with search engines, as we would be displaying different content than what the search engines see. If that is too problematic I would suggest to show a very obvious link to the duplicate in the answers section for anonymous users. What color can lightsabers be? I just saw the fan film  and the Force-sensitive bounty-hunter, Korbain Thor, wielded an ochre lightsaber (or at least that's what  described it as).   I'm just wondering if ochre is a canon color for a lightsaber? Peggy would like to prove to Victor that she knows the discrete logarithm of $y$ based $g$; that is, she knows $x$ such that $y = g^x \bmod p$. One round of the interactive proof protocol consists of the following steps.   Peggy picks random $k \in \mathbb Z/(p−1)\mathbb Z$, computes $t = g^k \bmod p$, and sends $t$ to Victor. Victor picks random $h \in \mathbb Z/(p−1)\mathbb Z$ and sends $h$ to Peggy. Peggy computes $r = (k − hx) \bmod (p − 1)$ and sends $r$ to Victor. Victor verifies that $t = g^r y^h \bmod p$.   The interactive protocol can be converted into a noninteractive zero-knowledge proof by choosing and making public a collision-resistant hash function $H$, and changing the second step of the interactive protocol to the following: Peggy computes $h = H(y, t)$. Then the noninteractive proof consists of $(t, h, r)$, which can be verified as follows: $$h = H(y, t), \qquad t \stackrel?= g^r y^h \bmod p.$$   What is the problem if in the non-interactive proof the hash $h$ depends only on $y$? That is, $h = H(y)$, and the proof consists of $(t, h, r)$, which can be verified as follows: $$h = H(y), \qquad t \stackrel?= g^r y^h \bmod p.$$ What is the problem if in the non-interactive proof the hash $h$ depends only on $t$? That is, $h = H(t)$, and the proof consists of $(t, h, r)$, which can be verified as follows: $$h = H(t), \qquad t \stackrel?= g^r y^h \bmod p.$$ How does entropy depend on location and scale? How to put a '+' sign inside a square like xor Force floats to be typeset after their occurrence in the source text? My wife has a Nikon D3100 that I've been using to film, but the battery typically won't last through long shoots.  I've gathered from searching around that I can't charge the camera with USB, but I wondered if there's ANY way to do that. It seems at least possible that an adapter could exist that would fill in for the battery and plug into the wall, but I haven't been able to find such a thing.  Is there such a product or technique? It would be nice to not buy a second battery, I'm really hoping for a "set it and forget it" solution. What ticket reservation do I need for a Schengen visa? I have a visa appointment this Friday 19 at the Italian Consulate in Philadelphia and I have a question about the flight reservation requirement: According to the Visa requirements "Confirmed flight reservation for a round trip showing complete itinerary."  Does this mean I have to reserve the tickets, pay and print the itinerary?  In this case if my visa gets denied then I will lose the money I paid or can I just show the planned itinerary (written not booked)? in this case the travel agency would not give me the Travel Insurance coverage until I book and pay for the reservation.   I am a US green card holder and applying from North Carolina. Performance of try-catch in php What kind of performance implications are there to consider when using try-catch statements in php 5?   I've read some old and seemingly conflicting information on this subject on the web before. A lot of the framework I currently have to work with was created on php 4 and lacks many of the niceties of php 5. So, I don't have much experience myself in using try-catchs with php. How to remove link for an application in new Google Launcher? How to insert spaces up to column X to line up things in columns? This is a really trivial question, but I've seen different conventions and some edits regarding which is correct, so I'm curious:  Should question titles be title-cased or sentence-cased? How do I disable Bootchart? I dont want a Bootchart to be generated on every startup. How do I disable bootchart ?  Once disabled, how do I re-enable bootchart ?  I don't mean uninstall. When cutting/copying some cells to paste them into another sheet/page, sometimes Excel freezes/locks up and fades out. At the top toolbar it says in brackets "not responding".  Eventually, I must click 'X' to close the program. It offers to wait for the program to respond, but never does – it just does nothing until I finally close it, where it offers to recover files etc.   Is there an issue with memory here? What can I do to stop it locking up? I converted a raster image to vector in Illustrator CS6 using Image Trace then the Expand option, though when I save as an svg the image looks embossed. I suspect it's due to the layer background being white and the paths not lining up, but I'm unsure how to fix it or prove that theory without manually having to adjust every path.   This is how it looks in Illustrator before I export it:    The image looks like this when saved/exported with art optimized option: I need to create file with name is the result of the command in Solaris I need to create only one file with name is the result of the command ls -l | head -2. I can't use environment variables. The filename must contain newline symbols.  I've tried to use touch 'ls -l | head -2', but it hasn't worked. How can I learn the basics of SharePoint 2013 in a few days? I have very little knowledge of SharePoint, and want to learn about SharePoint 2013.  Most of the resources that I've found are either about what's new in 2013, or they have a bunch of links to SharePoint 2010.  I also don't have the time to read a thousand page book.  A hundred or so would be fine.  Can anyone recommend a resource (site / book / video / tutorial) for a beginner to learn the basics of SharePoint 2013 in a few days?  I've downloaded a Kindle book, "Getting Started With SharePoint 2013."  It's perfect for absolute beginners, who just want to know how to upload &amp; download documents, but I'm looking for more than that. Ubuntu 15.10 is not in Boot Manager I have a problem with Ubuntu 15.10  I have in my computer windows 10. Some days ago i decided to install Ubuntu in partition so i can have both in the same hard drive. The problem is that i cant get into ubuntu, i dont have the grub up so i always go to Windows in default mode. The only way to go into ubuntu is with the CD of installation, when im on the grub of the cd i press Esc, then i text exit in command lines and i go to a boot manager in which i can choose the ubuntu system. Its a strange think because it is the only way i can get into ubuntu, i will like to solve this problem. I try many tutorials already of solving this problem. I didnt get any solution so i will like to ask u before doing another tutorial. Thank u Help me understand Support Vector Machines I understand the basics of what a Support Vector Machines' aim is in terms of classifying an input set into several different classes, but what I don't understand is some of the nitty-gritty details. For starters, I'm a bit confused by the use of Slack Variables. What is their purpose?  I'm doing a classification problem where I've captured pressure readings from sensors I've placed on the insole of a shoe. A subject will sit, stand, and walk for a couple of minutes while pressure data is recorded. I want to train a classifier to be able to determine whether a person is sitting, standing or walking and be able to do that for any future test data. What classifier type do I need to try? What is the best way for me to train a classifier from the data I've captured? I have 1000 entries for sitting, standing and walking (3x1000=3000 total), and they all have the following feature vector form. (pressurefromsensor1, pressurefromsensor2, pressurefromsensor3, pressurefromsensor4)