Like in subject. I got null pointer, how it is possible ?       java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference    public class MainActivity extends AppCompatActivity {     Button button, button2;     TextView textView, textView2;     String abc;     public List list = new ArrayList&lt;&gt;();     int size;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          list.add("abc");         abc = (String) list.get(0);          button.setOnClickListener(new View.OnClickListener() {             @Override             public void onClick(View view) {                 textView.setText(abc);             }         });          button2.setOnClickListener(new View.OnClickListener() {             @Override             public void onClick(View view) {                   size = list.size();                 textView2.setText(size);             }         });     } }
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 ways can N elements be partitioned into subsets of size K? What translation occurs when writing to a file that was opened in text mode that does not occur in binary mode? Specifically in MS Visual C.  unsigned char buffer[256]; for (int i = 0; i &lt; 256; i++) buffer[i]=i; int size  = 1; int count = 256;   Binary mode:  FILE *fp_binary = fopen(filename, "wb"); fwrite(buffer, size, count, fp_binary);   Versus text mode:  FILE *fp_text = fopen(filename, "wt"); fwrite(buffer, size, count, fp_text); Does GTA V Online Network Merge Xbox 360 and PS3 players? Looking for a 1000 most frequent english words Is there a free list of 1000 most frequent words used in everyday English? If there is a list with usage examples (as each of those words has multiple meanings for sure, not to cound phrasal verbs), it would be even greater.  Is there something alike, but with phrases? (E.g. 1000 most frequent phrases) Fastest converging method for calculating e I am looking for instructions on how to install cedarview graphics drivers on Ubuntu 13.04 32bit.  My graphics hardware is a GMA3600 aka Power VR SGX545.  EDIT: It seems that they are not in Raring yet, but only Precise:   EDIT2: they seem to be closed source. I am using QGIS and I created a vector grid on a crop field in order to cut it into plots. I want to save each grid cell into individual polygon shapefiles automatically.  Here is an example of a vector grid I would like to split into 117 shapefiles:    Eventually, I did it manually with the selection tool and "Save as" but it is really time-consuming when there are more than 100 plots to save.    Is there any way to do it faster and more automatically?  Each plot as an attribute named "Plot" that can discriminate against them (basically being id + 1). It's the attribute used here to label them. prove $\sum_{i=1}^{n}(x_i-\bar{x})^2\lt\sum_{i=1}^{n}(x_i-a)^2$ How do we prove that $$ \sum_{i=1}^{n}(x_i-\bar{x})^2\lt\sum_{i=1}^{n}(x_i-a)^2 $$  where $a$ is any value other than $\bar{x}$, the arithmetic mean.  My Attempt: $$ \sum_{i=1}^{n}(x_i^2-2x_i\bar{x}+\bar{x}^2)\lt\sum_{i=1}^{n}(x_i^2-2x_ia+a^2)\\\sum_{i=1}^{n}x_i^2-2\bar{x}\sum_{i=1}^{n}x_i+\sum_{i=1}^{n}\bar{x}^2\lt\sum_{i=1}^{n}x_i^2-2a\sum_{i=1}^{n}x_i+\sum_{i=1}^{n}a^2\\-2\bar{x}.n\bar{x}+n.\bar{x}^2\lt-2a.n\bar{x}+n.a^2\\-2\bar{x}^2+\bar{x}^2\lt-2a\bar{x}+a^2\\-\bar{x}^2\lt-2a\bar{x}+a^2 $$ But how do I proceed further or is there any better way ? What are good advanced books on the physics and science of photography? I am looking for books about the physics of DSLR, including modern photography optics and sensor electronics. If I already have some books on optics and electronics, I have found fairly hard to find good resource for these fields taking photography as a basis, with examples taken from photography and chapters dedicated to lenses optics for instance.  So far what I have found is either too generic, or, if dealing with photography, lacks the physical expertise I would like to get (I mean books with equations. Everybody loves them.)  Good books for physics of photography exist, but they are quite old, the last good I have found were written by Kingslake in the 70s and definitely miss the non-optical part, and the optical stuff is a bit old-fashioned now (but very nice books BTW).  To sum up, I would like:   Very technical references Dealing with physical issues specific to DSLRs and modern photography, such as diffraction limits, image stabilization, properties of coatings, noise correction - whatever you can think of actually...     EDIT: Based on the first results and a quick glimpse at the references given, I would recommend:   The  looks like a bible. Everything seems to be included. It could be a bit more technical, but it gives a lot of bibliography to go deeper if necessary. , for lighting  and  for sensor technology  and the somewhat easier  for optics   Not to forget the , wonderful resource. Schengen visa. What qualifies as main destination? I'm planning a multi city trip soon. I'll be applying with the German embassy as I had planned on going to Berlin for 3 days before going to Prague, Vienna, and Budapest for 2-3 days each afterwards.   My question is, it is working out more conveniently for me to instead make Germany my last destination, rendering the first entry clause. And I can only apply with the German consulate as they are the only ones I can find an appointment for in time. Would staying in Germany for 4 days afterwards be enough to classify it as a main destination (as opposed to 2-3 days in the other cities)? Firefox: Downloading files with drag and drop Identify story: Overpopulation problem causes people to live one day a week This story is about a man that is able to live every day of the week, while everybody else has a single day of wakefulness assigned to them. Due to overpopulation, each human spends 6 out of 7 days of the week in stasis, and has jobs assigned to them in daily shifts. 1/7 of the population works on Monday. 1/7 works on Tuesday, &amp; so on. The main character has found away to circumvent the process and illegally live out his days consecutively by skipping the stasis program that is imposed on the general population and by working a different job everyday. Can somebody name this scifi story? Merging multiple vector layers to one layer using QGIS A couple of months ago, I suggested a set of badges for . The responses were... mixed. The  can be summarized:  In practice, all this would do is encourage people to ask yet more stupid, worthless questions and we have quite enough of that as it is.  We believe that one of the main things holding back many of our beta sites is that when people have questions they aren't in the habit of asking on the site. Even our flagship site, Stack Overflow, doesn't get many questions from its most knowledgeable users. Perhaps they don't have questions, but far more likely they find answers without needing to ask. Our subtle bias against asking (questions =&gt; clueless) means we lose out on what might be our best source of excellent questions. So we went back to the drawing board and designed a badge set that should not encourage worthless questions:  Asked a well-received question on X separate days, and maintained a positive question record.  In order to award badges, we need to define our terms:  positive question record   (total questions - negative questions - closed - deleted)/total questions &gt;= 0.5  It triple counts a question that is downvoted, closed, and deleted. If you ask one that hits that trifecta, you'll need to ask three better questions to dig yourself out. My own record of asking does not meet the criteria:   (44 - 0 - 12 - 12)/44 = 0.4545...  My  looks a lot better; I had a bunch of questions from the beta period that have been subsequently (and rightfully) deleted. With care, I could bring my record into positive territory with 4 questions. The takeaway is that people can't sweep past indiscretions under the rug by deleting them. And they can recover from a bad start as long as they don't ask more bad questions.  well-received question on X separate days A well-received question is one that's open, not deleted, and has a score &gt; 0. If you ask at least one well-received question in a  and none of your questions that day are deleted, downvoted, or closed, you get one more day of credit toward the badge. Whenever the badge criteria is checked, previous asking days are re-evaluated so that there's an incentive to fix downvoted and/or closed questions. The no-deleted-questions criteria is to prevent people from asking several questions at once and deleting any that aren't upvoted or answered to ask another day. (Though this is a losing strategy in the long run.)   My proposed badge names and levels:  Asked a well-received question on 5 separate days, and maintained a positive question record.  Asked a well-received question on 30 separate days, and maintained a positive question record.  Asked a well-received question on 100 separate days, and maintained a positive question record. In addition, since some outstanding individuals ask on more than 100 days, the gold badge may be awarded multiple times. Over on English, Oishi-sama (now a ) would have a remarkable . Bronze and silver badges are only awarded once. We've decided to hold off on multiple awards for now. See the . Neither the names nor the levels nor even the descriptions are set in stone. Please play around with  to get an idea of how the badge works using our public data. Since the query does not account for deleted questions, it's a bit more generous than the actual badges would be. This version of the badge set should encourage a habit of well-received questions over time and encourage people to fix poorly received questions.  I'd like to express my gratitude to the Parenting community for participating in our . Should I be worried about electro-static discharge? Doing mostly micro-controller work, I have never bothered with grounding myself with a wrist-strap or any other implementation. Should I be worried about this? How serious is ESD when working at my workbench on projects? I am new to linux/ ubuntu and just downloaded the v11 of ubuntu to learn linux. I faced this "No root file system is defined" error while trying to install it. This is how I was proceeding -    Downloaded ubuntu v11 from the ubuntu.com website, wrote the iso into a bootable cd, and then got into the linux installation process on restarting; everything fine till here. In one of the screen during installation, there are three choices - install alongside windows, something else etc.. Since I have windows 7 in the C drive, I selected the first option - "Install alongside another OS".      Let me interrupt here to give my existing system details - HardDisk   size: 640GB.  Number of existing partitions - 5 C drive - label   windows - 160GB - has windows 7 installed D drive - label linux -   160GB - does not have any data E drive - label backup - 100GB - has   some data F drive - label entertainment - 100GB  - has some data G   drive - label work - 90GB  - has some data All of the above are in   NTFS format.    In the screen that follows, an image is shown with 2 parts and each part is shown to have size equal to 80GB. There is a horizontal slider in the middle of these two images, with which I can resize the partitions. The right side partition is labeled Linux. There is also an option to do 'advanced partitions'. On clicking advanced partitions on the above screen, a new screen is shown in which the partitions existing in my computer are shown - but the labels are different. I see that there are two partitions with size = 160GB each (as expected), and so I assumed that the first 160GB would be my existing C drive and the second on would be the partition which I had labeled as linux (drive D). So I selected the linux partition and clicked on proceed/ install now, and then this error was shown - "No root file system defined".. and I cannot proceed after this.   Please let me know two things here:   During the screen in point number 3 above, the image with slider was shown. Which partition (drive c: or d: or anyother) is being referred to here? Which one am I actually resizing - is it the existing c: drive which has windows 7 installed already, that is getting shrunk and then ubuntu getting installed in the remaining space? What does ""No root file system defined" error mean? How do I select the proper partition and continue with the installation?    P.S.:  I had already partitioned my drives as mentioned above, and the D drive with 160GB was specifically left free for installing ubuntu. I would like to Select D drive during setup and install ubuntu here, while still keeping the already installed windows7 in C drive.  Thanks! How do I check an iOS device's battery health? Skipping acquire of configured file 'contrib/binary-i386/Packages' as repository ... doesn't support architecture 'i386' I installed Ubuntu 18.04 and then while installing Virtualbox i get the 'i386' error message after I did:  $ sudo apt-get update Get:1 http://nl.archive.ubuntu.com/ubuntu bionic InRelease [242 kB] Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease                                                                 Hit:3 http://ppa.launchpad.net/danielrichter2007/grub-customizer/ubuntu bionic InRelease                                          Hit:4 http://nl.archive.ubuntu.com/ubuntu bionic-updates InRelease Hit:5 http://nl.archive.ubuntu.com/ubuntu bionic-backports InRelease Get:6 http://download.virtualbox.org/virtualbox/debian bionic InRelease [4429 B] Get:7 http://download.virtualbox.org/virtualbox/debian bionic/contrib amd64 Packages [1426 B] Fetched 248 kB in 1s (209 kB/s)      Reading package lists... Done N: Skipping acquire of configured file 'contrib/binary-i386/Packages' as repository 'http://download.virtualbox.org/virtualbox/debian bionic InRelease' doesn't support architecture 'i386'   I found several answers on Askubuntu for the 'i386' message but I don't know how to apply this to my situation When to use 'which' or 'in which' or 'that' (as relative pronouns)? I am confused about when to use:  'which' vs 'in which' vs or 'that'?    Would you please explain it as a writing rule? Here I have an example:       Authors reported shortened growth period and slower radial growth rate for low soil water potential which is directly attributed to the decrease in water potential, rather than to the constraints on carbon availability. After writing the FreeNAS IMG to a 16 GB USB flash drive, I can now only use 938 MB. I used the Win32 Disk Imager tool to write the IMG to the device. Then later, when I inserted the the USB drive into my Windows 7 computer it said that it had to be formatted, because it couldn't read it. I believe this is normal. So I formatted it inside Windows using the format option when prompted. So in Windows Explorer now, 938 MB is reported as capacity of this device.    Also, when i check the properties dialog box I can see the same numbers.    And when I check with diskmgmt.msc I can see there are several volumes I don't recognize and unallocated space of 12.79 GB.    Now, I have another 2 GB USB flash drive with the same problem. It too was used for FreeNAS, and it too has a reported capacity of only 938 MB. I thought it was broken there for a while, until I saw the same problem with this 16 GB model.  I tried using diskpart on the 2 GB model, and I saw that there were several partitions there (list partitions) just like on this one. So I used the clean option to try to wipe it, but that wiped off everything so it's totally useless now. I'm not sure how to rebuild it.  Is this a standard routine, like part of the whole "user experience", that whenever you make a bootable USB falsh drive with FreeNAS, it messes up your device? I am new to FreeNAS, so i wouldn't know. But it sure looks like it. Maybe it is in fact the format operation in Windows that messes things up... I don't know. It's not very nice.  How do I restore the capacity back to 16 GB-ish (14.9 GiB)?