I am trying to add same values on listView by user clicks, when user clicks a button, the system graps the value of two EditTexts and add it into the list.  But when I click a button Error displays:     01-14 12:46:31.623 21297-21297/com.example.transportor   E/AndroidRuntime: FATAL EXCEPTION: main       Process: com.example.transportor, PID: 21297       java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object   android.content.Context.getSystemService(java.lang.String)' on a null   object reference           at android.widget.ArrayAdapter.init(ArrayAdapter.java:310)           at android.widget.ArrayAdapter.(ArrayAdapter.java:153)           at com.example.transportor.product_list_adapter.(product_list_adapter.java:24)           at com.example.transportor.ui.home.HomeFragment$1.onClick(HomeFragment.java:59)           at android.view.View.performClick(View.java:4757)           at android.view.View$PerformClick.run(View.java:19757)           at android.os.Handler.handleCallback(Handler.java:739)           at android.os.Handler.dispatchMessage(Handler.java:95)           at android.os.Looper.loop(Looper.java:135)           at android.app.ActivityThread.main(ActivityThread.java:5235)           at java.lang.reflect.Method.invoke(Native Method)           at java.lang.reflect.Method.invoke(Method.java:372)           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)   My Homefragment:   Context mcontext;  Button addListe = (Button)root.findViewById(R.id.addL);         final ListView productListe = (ListView)root.findViewById(R.id.productList);         addListe.setOnClickListener(new View.OnClickListener() {             @Override             public void onClick(View v) {                 product_list PL = new product_list(quantity.getText().toString(),produit.getText().toString());                 ArrayList&lt;product_list&gt; PLL = new ArrayList&lt;&gt;();                  PLL.add(PL);                 product_list_adapter p_l_a = new product_list_adapter(mcontext,R.layout.adapter_product_list,PLL);                 productListe.setAdapter(p_l_a);             }         });   and My Product list:    private String quantity;     private String product;      public product_list(String quantity, String product) {         this.quantity = quantity;         this.product = product;     }      public String getQuantity() {         return quantity;     }      public void setQuantity(String quantity) {         this.quantity = quantity;     }      public String getProduct() {         return product;     }      public void setProduct(String product) {         this.product = product;     }   and product_list_adapter:   private Context mContext;     int mRessource;     public product_list_adapter(@NonNull Context context, int resource, @NonNull ArrayList&lt;product_list&gt; objects) {         super(context, resource, objects);         this.mContext = mContext;         mRessource = resource;     }        @NonNull     @Override     public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {         //get infos         String quatity = getItem(position).getQuantity();         String product = getItem(position).getProduct();         product_list PL = new product_list(quatity,product);         LayoutInflater iniat = LayoutInflater.from(mContext);         convertView = iniat.inflate(mRessource,parent,false);         TextView Tquantity = (TextView)convertView.findViewById(R.id.TextView1);         TextView Tproduct = (TextView)convertView.findViewById(R.id.TextView2);         Tquantity.setText(quatity);         Tproduct.setText(product);         return convertView;      }
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?
Which airlines allow in-cabin pets on transatlantic flights? Kronecker delta confusion I'm confused about the Kronecker delta. In the context of four-dimensional spacetime, multiplying the metric tensor by its inverse, I've seen (where the upstairs and downstairs indices are the same):  $$g^{\mu\nu}g_{\mu\nu}=\delta_{\nu}^{\nu}=\delta_{0}^{0}+\delta_{1}^{1}+\delta_{2}^{2}+\delta_{3}^{3}=1+1+1+1=4.$$  But I've also seen (where the upstairs and downstairs indices are different):  $$g^{\mu\nu}g_{\nu\lambda}=\delta_{\lambda}^{\mu}=\left(\begin{array}{cccc} 1 &amp; 0 &amp; 0 &amp; 0\\ 0 &amp; 1 &amp; 0 &amp; 0\\ 0 &amp; 0 &amp; 1 &amp; 0\\ 0 &amp; 0 &amp; 0 &amp; 1 \end{array}\right).$$  How can there be two different answers to (what appears to me to be) the same operation, ie multiplying the metric tensor by its inverse? Apologies if I've got this completely wrong. Is "funnest" a word? We seem to be stuck at an impasse on this issue.  Is funnest a word or not?  If so, does it mean "most fun"? Does any test actually prove causation? C++ compiling on Windows and Linux: ifdef switch mysql database no space available What DC motor specs do I need to lift a weight with certain gear configuration I came across this strange limit whilst showing convergence of a series: $$\lim_{n \to \infty}\sqrt[n]{\frac{2^n+3^n}{3^n+4^n}}$$ How can I calculate this limit? Why does rubbing feet against sheets create a spark? Sometimes when I'm in bed at night, I rub my feet against the sheets and light is created. What exactly is going on?     I'm familiar with static electricity, and the triboelectric effect (creating a charge by rubbing 2 insulators together), and electrostatic discharge (releasing charge by touching a grounded conductor).     I believe that all of that is what is at work here, but I'm slightly confused since in other cases, the triboelectric effect and electrostatic discharge seem to occur as two separate steps, with different substances involved, and here, the two effects seem to be occurring simultaneously, with the same substances.     Can someone help me with a step-by-step explanation of the dynamics of what is going on? Recently I've noticed more and more sign-in / sign-up workflows defaulting to the sign-up option first and providing a minimal "Sign-In / Login" action somewhere else on the page. What's the reason behind this practice?  Examples where I've seen this recently: What is the formula for percent of frame filled at a specific distance and focal length? When I see someone else being embarrassed / humiliated, for example a singer forgetting their words in a concert, I would say something like "I feel embarrassed for them". But is there a better word to describe this feeling?  I would say it's a mix of:   Empathetic discomfort for someone else's humiliation Tension; hope that spectators will be forgiving Frustration that I cannot help them   Other scenarios I would feel the same emotion:   Seeing someone make a presentation, the slides are all out of order, and their face gets red with embarrassment while there's a tense silence in the room. Seeing someone make an embarrassing social blunder in front of unforgiving people. Seeing a speaker who keeps making a distracting and annoying gesture, and they don't realize that the whole audience is annoyed. Seeing someone be taken advantage of, like seeing someone naively and happily accept a terrible offer on a car. Seeing a person of strong image (for example the CEO of your company) do something like accidentally leave their webcam on after a conference call, and employees see him/her let out a big burp and pick their nose or something.   In these cases it's important that the audience is not forgiving, even if they don't confront the person about it. The person may or may not know they are being humiliated.  "Pity" as proposed in an answer seems very close, but I think it lacks a few components. I think "pity" has a chronic connotation - that you are referring to the general state of things rather than a specific event.  I think "pity" also depends on the subject suffering, but in my example they are often oblivious.  It could very well be that there is no word for this at all.  NOTE: Some people do not feel the same way I do in this scenario, so you may not think this question makes any sense. What is the most efficient way to deep clone an object in JavaScript? What is the most efficient way to clone a JavaScript object? I've seen obj = eval(uneval(o)); being used, but . I've done things like obj = JSON.parse(JSON.stringify(o)); but question the efficiency.  I've also seen recursive copying functions with various flaws.  I'm surprised no canonical solution exists. How do you construct a std::string with an embedded null? If I want to construct a std::string with a line like:  std::string my_string("a\0b");   Where i want to have three characters in the resulting string (a, null, b), I only get one.  What is the proper syntax? Would changing IP addresses affect my SEO We're about to change our website from a shared hosting account to run on a VPS, mainly so we have our own resources and control over server settings.   An IP address is included with the VPS. What I was wonder is if the IP address change will have a similar affect to changing the domain name?   Obviously the links will still come from the same domain, so that's fine, but I was thinking more along the lines of the way a search engine sees the site - would it downgrade you for switching IP's? What does a binomial coefficient with commas mean? I'm reading through  paper (on Dyck Paths). Near the middle of the second page, the author states the following:     Remark For the set $h_n$ there are ${k\choose t_1, t_2, ... , t_m }$ $n + k \choose{k}$ $=$ $ n + k\choose {n, t_1, t_2, ..., t_m}$ different Dyck paths.   What does ${k\choose t_1, t_2, ... , t_m }$ mean? I know what the binomial coefficient is, but I'm not sure how to interpret it when one of the parameters is a set. Optimal bcrypt work factor Disable automatic activation of Gnome Shell activities on mouse over pgfplots from file: search path, looking for \graphicspath equivalent What does "end to end" mean in deep learning methods?