NullPointerException while trying to set click listener on button which is on bottomsheet i have recyclerview in my App and when list item is pressed bottomsheet dialog expends where i have two buttons but i can't set click listeners to it. This is onClick method in adapter  BottomSheetDialog offer_info_dialog; RelativeLayout rel; Button Yes,No; View parentView; @Override public void onClick(View view) {     rel = (RelativeLayout) activity.findViewById(R.id.bottomsheet);     Yes = (Button) offer_info_dialog.findViewById(R.id.confirm_btn_on_info);     No = (Button) offer_info_dialog.findViewById(R.id.cancel_btn_on_info);         offer_info_dialog = new BottomSheetDialog(context);         LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );         parentView = inflater.inflate(R.layout.offer_info_layout, null);         offer_info_dialog.setContentView(parentView);         ((View) parentView.getParent()).setBackgroundColor(context.getResources().getColor(android.R.color.transparent));         offer_info_dialog.show();         rel.setVisibility(View.INVISIBLE);      Yes.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View v) {             MainActivity.removeCheatOfferMarkers(2);         }     });      No.setOnClickListener(new View.OnClickListener() {         @Override         public void onClick(View v) {             BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from((View) parentView.getParent());             bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);         }     });     offer_info_dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {         @Override         public void onDismiss(DialogInterface dialog) {             rel.setVisibility(View.VISIBLE);         }     });  }   and this is an error:  java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.support.design.widget.BottomSheetDialog.findViewById(int)' on a null object reference
What is a NullPointerException, and how do I fix it? 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?
Complement property of DES I'm supposed to show the complement property of DES ($c=DES(p,k) =&gt; \bar c = DES(\bar p, \bar k)$).  My idea was to just start the algorithm with $\bar p$ and see what happens (ignoring the initial permutation for now). I looked at it step by step and got the the point where $R1 = \bar L1 \oplus f(\bar k1, \bar R0)$. So I figured I had to show that $f(\bar k1, \bar R0) = \bar f(k1,R0)$. Is that even right so far? Because I got stuck at the point where the S-Boxes are used. Why would $S(\bar x) = \bar S(x)$?  Somewhere else I read something about a formal prove using induction, but I don't know how I would do that either... Assume that $X$ and $Y$ are two random variables such that $Y=E[X|Y]$ almost surely and $X= E[Y|X]$ almost surely. Prove that $X=Y$ almost surely.   The hint I was given is to evaluate: $$E[X-Y;X&gt;a,Y\leq a] + E[X-Y;X\leq a,Y\leq a]$$  which I can write as: $$\int_A(X-Y)dP +\int_B(X-Y)dP$$ where $A=\{X&gt;a, Y\leq a\}$ and $B=\{X\leq a,Y\leq a\}$.  But I need some more hints. Proofs of AM-GM inequality The arithmetic - geometric mean inequality states that $$\frac{x_1+ \ldots + x_n}{n} \geq \sqrt[n]{x_1 \cdots x_n}$$ I'm looking for some original proofs of this inequality. I can find the usual proofs on the internet but I was wondering if someone knew a proof that is unexpected in some way. e.g. can you link the theorem to some famous theorem, can you find a non-trivial geometric proof (I can find some of those), proofs that use theory that doesn't link to this inequality at first sight (e.g. differential equations …)?  Induction, backward induction, use of Jensen inequality, swapping terms, use of Lagrange multiplier, proof using thermodynamics (yeah, I know, it's rather some physical argument that this theorem might be true, not really a proof), convexity, … are some of the proofs I know. If every ideal is principal show the same is true for the image of a homomorphism. Can I travel in UK before switching to a study visa? As I read in general visitor visa Terms &amp; Condition, I would only be granted to stay up to 6 months in UK. However I am planning to apply for General Student Visa to further my studies. Would it be possible for me to enter UK as visitor for first 6 months/less before I apply for student visa in the same year if I want to travel and study on the same year? Can I switch the User-Agent header for only a single web site? Plot x=3 in PGFPlots What UML (Unified Modelling Language) tools are available? Is there any adjustment required when computing the correlation coefficient between:   continuous and discrete variable  two discrete variables ?    Thanks ! Name for the center amplitude of a sine wave I am trying to find the name for the value at the center of a sine wave $$ y(t) = A\sin (kx \pm \omega t+\varphi) + D $$ i.e. the offset $D$ of the wave in the $y$-direction.  calls it Center Amplitude, but further googling this name is difficult and does not provide any further sources. I also found the expression , but I'm not sure that it refers to the same thing. Is there a commonly used name for the $y$-direction-offset of a sine wave? On a series involving harmonic numbers Android: Using default styles Catching access violation exceptions? Example  int *ptr; *ptr = 1000;   can I catch memory access violation exception using standard C++ without using any microsoft specific. Notify on retagging A question here on meta for instance may stick around for quite a while. A feature-request  maybe even for months. Then the status (tags) gets changed to  or  or whatever and the OP does not get notified.  On a normal post-edit we get a notification but retagging does not count for that. Please add retagging to the edit notifications. I've seen them maneuver. They definitely can go backwards. How fast can they go in reverse? Is warp speed possible, or is reverse limited to impulse power? If it is limited to impulse power, can they travel backwards under impulse power as fast as they travel forwards under impulse power? Can I define keyboard shortcuts using the Super key? Why is the Java plugin (JRE) disabled in Chrome? Why is the Java plugin (JRE) is disabled in Chrome? It is some security concern?  From official Java website:     Chrome no longer supports NPAPI (technology required for Java applets)   The Java plug-in for web browsers relies on the cross platform plugin architecture NPAPI,   which has been supported by all major web browsers for over a decade.   Google's Chrome version 45 (scheduled for release in September 2015) drops support   for NPAPI,   impacting plugins for Silverlight, Java, Facebook Video   and other similar NPAPI based plugins.   But anyone knows why? How it could be dangerous for Chrome user with latest version of Java JRE installed? Subquery in SQL Server Compact Edition Prove: if $|z|=1$ than $\frac{z+1}{z-1}$ is an imaginary number Prove: if $|z|=1$ than $\frac{z+1}{z-1}$ is an imaginary number    I have tried to look at $$\frac{z+1}{z-1}=\frac{z+1}{z-1}\cdot \overline{\frac{z-1}{\overline{z-1}}}=\frac{z+1}{z-1}\cdot \frac{\overline{z}-1}{\overline{z}-1}$$  But did not get far Blender 2.8 - Transparent background