getting error that null pointer exception has occurred and trying to invoke virtual method  public class after10th extends AppCompatActivity {      ArrayAdapter&lt;String&gt; adapter;      @Override     protected void onCreate(@Nullable Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.after10th);          ListView lv = (ListView) findViewById(R.id.searchten);         ArrayList&lt;String&gt; after_ten = new ArrayList&lt;&gt;();         after_ten.addAll(Arrays.asList(getResources().getStringArray(R.array.after_ten)));          adapter = new ArrayAdapter&lt;&gt;(after10th.this, android.R.layout.simple_list_item_1, after_ten);          lv.setAdapter(adapter);      }      @Override     public boolean onCreateOptionsMenu(Menu menu) {         MenuInflater inflater = getMenuInflater();         inflater.inflate(R.menu.menu_search, menu);         MenuItem item = menu.findItem(R.id.menusearchten);         SearchView searchView = (SearchView) item.getActionView();         searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {             @Override             public boolean onQueryTextSubmit(String query) {                 return false;             }              @Override             public boolean onQueryTextChange(String newText) {                  adapter.getFilter().filter(newText);                 return false;             }         });                  return super.onCreateOptionsMenu(menu);`enter code here`     }  }   This is the error:  09-23 19:09:17.242 9000-9000/com.example.supriya.career_guidance E/AndroidRuntime: FATAL EXCEPTION: main  Process: com.example.supriya.career_guidance, PID: 9000  java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.SearchView.setOnQueryTextListener(android.widget.SearchView$OnQueryTextListener)' on a null object reference
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?
Lightning aura:iteration over two objects with dynamic key I want to do simple thing - I want to iterate over list of two objects and use displayColumns as dynamic keys to get values from selectList object:  &lt;aura:attribute name="displayColumns" type="String[]"/&gt; &lt;aura:attribute name="selectList" type="Object[]"/&gt;   &lt;table&gt;     &lt;aura:iteration items="{!v.selectList}" var="elem"&gt;     &lt;tr&gt;         &lt;aura:iteration items="{!v.displayColumns}" var="col"&gt;             &lt;td&gt;{!elem[col]}&lt;/td&gt;         &lt;/aura:iteration&gt;     &lt;/tr&gt;     &lt;/aura:iteration&gt; &lt;/table&gt;   In pure JS I would do: elem[col.value], but in lightning compiler returns:      expecting a positive integer, found 'col' at column 6 of expression:   elem[col.value]: Source   Is there any workaround without creating proper object structure in controller? I want to have a script that takes the current working directory to a variable. The section that needs the directory is like this dir = pwd. It just prints pwd how do I get the current working directory into a variable? What is the center of $D_{2n}/Z(D_{2n})$ What is the center of $D_{2n}/Z(D_{2n})$. I see that when $n=2^k$ then I have a $p$-group so the center is not trivial. But when $n$ is not power of $2$ how can i know what is the center of this group?. Surely when $n$ is odd then the center is trivial. Why isn’t the definite article used in "The commission commanded that work [...] should cease"? Can RUBIK's cube be solved using group theory? If yes, how can we use it to solve a $2\times2$ Rubiks Cube? We've got a Windows 10 installation running in an environment where it can occasionally lose power and restart. However, this sometimes leads to corruption of files.  I've had a look at Windows "To-Go" but this seems to be persistent. And I've also checked out virtualisation, but that would require us to run a non-persistent Windows 10, in another Windows 10 environment.  Is it possible to install Windows 10 as a "non-persistent live CD"? So that a user will have a seemingly fresh Windows 10, but doesn't require to re-install it at each startup? When IE10 is set as my default browser, double-clicking an internet shortcut (*.url file) opens it in a new tab of the existing IE window. However, when it is not the default, every way of opening a *.url that I've tried brings up a new IE window per file. Is it possible to keep opening files in new tabs of the same IE window when it's not set as the default browser, and how?  What I've tried and it didn't work:   "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "C:\Dir1\file.url" (opens a new window every time) C:\Windows\System32\rundll32.exe "C:\Windows\System32\ieframe.dll",OpenURL C:\Dir1\file.url (opens the default browser) classexec "C:\Dir1\file.url" --class htmlFile (using  utility, opens a new window every time)   I use Windows 7 x64. Probability of lim sup, lim inf for sequence of random variables. Maybe this is extremely simple, but i havent found a specific answer for this online.  For a sequence of independent continuous random variables $X_n$ ,$n=1,2,3,...$ , all with the same probability density function $f(x)&gt;0$ for all real $x$, and a specific real number $b$, what do the following events mean in simple terms and what is the probability of each?  a)$\lim_n\sup\{X_n \gt b\}$ b)$\lim_n\inf\{X_n \gt b\}$ c)$\lim_n\sup\{X_n \le b\}$ d)$\lim_n\inf\{X_n \le b\}$ How to determine function name from inside a function Induction Proof: Fibonacci Numbers Identity with Sum of Two Squares Using induction, how can I show the following identity about the fibonacci numbers? I'm having trouble with simplification when doing the induction step.  Identity: $$f_n^2 + f_{n+1}^2 = f_{2n+1}$$  I get to:  $$f_{n+1}^2 + f_{n+2}^2$$  Should I replace $f_{n+2}$ using the recursion? When I do that, I end up with the product of terms, and that just doesn't seem right. Any guidance on how to get manipulate during the induction step?  Thanks! Trace map from finite surjective morphism of normal irreducible varieties Electric potential is related to Electric Field by negative integral of Field with distance.If charges move away from the positive terminal (Assuming conventional flow) why is there no drop in electric potential even though the charges are moving in the direction of electric field?  Some of the answers I read for the similar question said that the electrons in wires rearrange themselves in a way to make the electric field uniform in the wire.However,this doesn’t explain the absence of potential drop in the wires (due to electric field) since the field is still there. What's the best way to parse an XML dateTime in Java? How can I prove that if $n$ is even then $n^2$ is even and if $n$ is odd then $n^2$ is odd? How to negate a specific symbol? I want to negate the symbol whose code is \models (this would be specific to Formal Logic). How can I do that? I tried a number of combination, but didn't find how this could be done. I tried \neqmodels, \nemodels, \notmodels, \nmodels  but all of them are wrong.  Is there a general way to negate symbols? Scale Space Between Multiple Objects If I have multiple objects selected can I use scaling to make the objects closer together (without rescaling the objects)? Same update keeps showing up everyday In  (ignoring Hawking radiation), why is a  black? Why nothing, not even light, can escape from inside a black hole? To make the question simpler, say, why is a  black hole black? Why wave theory cannot explain photoelectric effect and provides evidence for particle nature of light? How can I check the SMART status of a SSD or HDD on current versions of Ubuntu 14.04 through 20.04?