I've got an issue with setting an adapter to the ViewPager. Each time i get a NullObjectReference error. What's wrong with my code?  1) Layout:  &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt;  &lt;android.support.v4.view.ViewPager     android:id="@+id/view_pager"     android:layout_width="match_parent"     android:layout_height="wrap_content"&gt;      &lt;android.support.v4.view.PagerTabStrip         android:id="@+id/pager_header"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_gravity="top"         android:paddingBottom="4dp"         android:paddingTop="4dp" /&gt;  &lt;/android.support.v4.view.ViewPager&gt; &lt;/LinearLayout&gt;   2) Java class:  public class FoodFragment extends Fragment {  Toolbar toolbar; ViewPager viewPager; TabsPagerAdapter pagerAdapter;   @Override public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState); }  @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,                          Bundle savedInstanceState) {      setRetainInstance(true);        ((AppCompatActivity)getActivity())     .getSupportActionBar().setDisplayShowTitleEnabled(true);     ((AppCompatActivity)getActivity())     .getSupportActionBar().setTitle(R.string.food);     toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);     toolbar.setBackgroundColor(Color.parseColor("#f6a632"));      pagerAdapter = new    TabsPagerAdapter(getActivity()    .getSupportFragmentManager());     viewPager = (ViewPager) getActivity().findViewById(R.id.view_pager);     viewPager.setAdapter(pagerAdapter);      return inflater.inflate(R.layout.fragment_food, container, false); } }   I always get this error when calling   viewPager.setAdapter(pagerAdapter); line.
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?
No processing tools in QGIS 3.2 How can I compare time in SQL Server? I have an ex who has posted nude photos of me online in the past, linked to my online social media, and posted my full name and where I live. I am concerned he may do so again once he finds out I'm now in a PhD program (he's very jealous of any success I have), and may link to my school bio page, or worse.   Revenge porn is illegal in my state, and the case against him is currently pending. I have also gotten the photos taken down with a DMCA letter (I hold the copyright over the photos in question). At this point, I am concerned with how a future attempt could affect my career.  I can handle the embarrassment now that I've been through it once, so if that's the biggest concern, I can deal. I just don't want to lose a career over it, given how small academia really is and how a reputation might follow one around.  My question is, if I don't change my name (I've considered this, assuming I can keep him from finding out) and my photos are circulated and discovered by faculty or students, how likely am I to be thrown out of my PhD program or later lose a job as an untenured prof? Is a name change worth it?   (If it makes any difference, they are essentially just topless portraits; I'm not engaged in any sexual activity or anything weird, and were taken 10 years ago when I was very young and foolish.) How does the secondary effect of the Heat Metal spell work? The  spell description states:  If a creature is holding or wearing the object and takes the damage from it, the creature must succeed on a Constitution saving throw or drop the object if it can. If it doesn't drop the object, it has disadvantage on attack rolls and ability checks until the start of your next turn...  I am unsure how this disadvantage mechanic functions as a whole. When do you suffer from it and in what ways (if any) can you end it? For example: What happens if you fail the save but cannot drop the object? Does dropping the object later, on your turn, do anything? What happens if you succeed on the save?  Does dropping the object later, on your turn, do anything? I would like it to be assumed that ; however, heat metal can still force you to drop the weapon. I would also like it to be assumed that . Forcing series convergence Convert XML/HTML Entities into Unicode String in Python Can't log in using Firefox in Stack Overflow Here's what is happening; everytime I go to Stack Overflow (stackoverflow.com, NOT meta) with Firefox, it gives me the "Welcome back" tab that pops up from the top. Whenever I click in the "click here to refresh the page" link, all it does is refresh the page without logging me back in.  Even if I try to log in using the "log in" button at the top, all it does is pop up the tab that says "Welcome name here, you're being redirected." The problem is I'm not being logged in, not to mention that it keeps refreshing the page over and over again without giving me a choice to log in with Facebook.  For some reason, I was capable of logging in to Meta Stack Overflow using Firefox. I am still unable to log in to Stack Overflow. Any ideas? Does the Force wane as you age? @Valorum said     ...not to mention the sheer strain that comes from continually using the Force at an advanced age.   To my feeble mind, this doesn't make sense. Approaching 900 years old, Yoda is still as strong as any whippersnapper in terms of Force power and usage. Despite his old age, Obi Wan shouldn't have any problems with using his Force powers.  This got me to thinking, does the Force begin to leave you as you age? Is it a flow of Force power that goes down based on (I hate to say this) a decrease in midichlorian count as you approach your expiration date? The indexer into Dictionary throws an exception if the key is missing.  Is there an implementation of IDictionary that instead will return default(T)? I know about the TryGetValue() method, but that's impossible to use with LINQ. Would this efficiently do what I need?: myDict.FirstOrDefault(a =&gt; a.Key == someKeyKalue);  I don't think it will as I think it will iterate the keys instead of using a Hash lookup. Have the guys from the show Impractical Jokers gotten into any major trouble because of the nature of their show?   Eg: have they been physically assaulted or has anyone thrown a law suit on them? How can I analytically prove that randomly dividing an amount results in an exponential distribution (of e.g. income and wealth)? In this current  the following is being proposed:      Suppose you randomly divide 500 million in income among 10,000   people. There's only one way to give everyone an equal, 50,000 share.   So if you're doling out earnings randomly, equality is extremely   unlikely. But there are countless ways to give a few people a lot of   cash and many people a little or nothing. In fact, given all the ways   you could divvy out income, most of them produce an exponential   distribution of income.   I have done this with the following R code which seems to reaffirm the result:  library(MASS)  w &lt;- 500000000 #wealth p &lt;- 10000 #people  d &lt;- diff(c(0,sort(runif(p-1,max=w)),w)) #wealth-distribution h &lt;- hist(d, col="red", main="Exponential decline", freq = FALSE, breaks = 45, xlim = c(0, quantile(d, 0.99)))  fit &lt;- fitdistr(d,"exponential") curve(dexp(x, rate = fit$estimate), col = "black", type="p", pch=16, add = TRUE)     My question How can I analytically prove that the resulting distribution is indeed exponential?  Addendum Thank you for your answers and comments. I have thought about the problem and came up with the following intuitive reasoning. Basically the following happens (Beware: oversimplification ahead): You kind of go along the amount and toss a (biased) coin. Every time you get e.g. heads you divide the amount. You distribute the resulting partitions. In the discrete case the coin tossing follows a binomial distribution, the partitions are geometrically distributed. The continuous analogues are the poisson distribution and the exponential distribution respectively! (By the same reasoning it also becomes intuitively clear why the geometrical and the exponential distribution have the property of memorylessness - because the coin doesn't have a memory either). "pros and cons", "black and white", "ups and downs". Always in a fixed sequence, is there a word or phrase for these? Is there a word or phrase for two nouns or adjectives joined by a conjunction (usually "and") in a fixed sequence?        alive and well           fast and furious   hat and gloves   pen and pencil   law and order   wit and wisdom   salt and pepper   bacon and eggs   horse and carriage   Adam and Eve   ladies and gentlemen   loud and clear   heads or tails   yes or no   dead or alive Date and time panel is greyed out, how do I restore it? Date and time is showing in the login screen (unity-greeter) but not when I login to my session.  When I go to date and time settings the panel is all grey :    Any idea how to recover from this ? Why is '.' a hard link in Unix? I am wondering what sudo apt-get update does?  What does it update? Compiler error C3493: 'func' cannot be implicitly captured because no default capture mode has been specified How do you convert a byte array to a hexadecimal string, and vice versa? Old Sci-Fi book with skin crystalizing disease and characters with psi powers Explicitly accept change for PPA 'Label' When I run apt-get update on my ubuntu 17.10 I receive the following error:  E: Repository 'http://ppa.launchpad.net/ondrej/php/ubuntu artful InRelease' changed its 'Label' value from '***** The main PPA for PHP (5.6, 7.0, 7.1) with many PECL extensions *****' to '***** The main PPA for supported PHP versions with many PECL extensions *****' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details."   The man page doesn't really point to a solution.  My question is, how do I explicitly accept the change? If A and B are correlated with C, why are A and B not necessarily correlated?