Everything working fine i got this error at the end please give solution. I have tried each and every solution, I don't know what to do.. please give the exact solution trying from past 2 days but i can't solve the problem..  Thanks in advance  public double calculatedDistance(DataSnapshot dataSnapshot ) {           HashMap&lt;String, Object&gt; values = (HashMap&lt;String, Object&gt;) dataSnapshot.getValue();          double lati = Double.parseDouble(values.get("latitude").toString());         double longi = Double.parseDouble(values.get("longitude").toString());          double xSquare = Math.pow(lat-lati, 2);         double ySquare = Math.pow(lng-longi, 2);         double distance = Math.sqrt(xSquare + ySquare);          //double dist = distance;          textViewdistance.setText(String.valueOf(""+distance+""+"km"));         return distance;      }   Error in Logcat  E/AndroidRuntime: FATAL EXCEPTION: main     Process: com.example.ambulance, PID: 17399     java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference         at com.example.ambulance.MapsActivity.calculatedDistance(MapsActivity.java:451)         at com.example.ambulance.MapsActivity$2$1.onChildAdded(MapsActivity.java:178)         at com.google.firebase.database.core.ChildEventRegistration.fireEvent(com.google.firebase:firebase-database@@19.2.0:79)         at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@19.2.0:63)         at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@19.2.0:55)         at android.os.Handler.handleCallback(Handler.java:907)         at android.os.Handler.dispatchMessage(Handler.java:105)         at android.os.Looper.loop(Looper.java:216)         at android.app.ActivityThread.main(ActivityThread.java:7625)         at java.lang.reflect.Method.invoke(Native Method)         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
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?
Extrude Faces along Local Normals I am trying to extrude faces of a cylinder along local normals. 3dsmax can do it easy, couldn't find how to do it in blender.  The extrude region option extrudes it as shown in the first example. I want it done like the 2nd example. Can there be a function that's even and odd at the same time? How to delete a file with a path too long to be deleted When programming interfaces, I've found I'm doing a lot of casting or object type conversion.  Is there a difference between these two methods of conversion?  If so, is there a cost difference or how does this affect my program?  public interface IMyInterface {     void AMethod(); }  public class MyClass : IMyInterface {     public void AMethod()     {        //Do work     }      // Other helper methods.... }  public class Implementation {     IMyInterface _MyObj;     MyClass _myCls1;     MyClass _myCls2;      public Implementation()     {         _MyObj = new MyClass();          // What is the difference here:         _myCls1 = (MyClass)_MyObj;         _myCls2 = (_MyObj as MyClass);     } }   Also, what is "in general" the preferred method? How to solve a difference equation? So I have the difference equation $4y_{k+1} = 2y_k$.  I need to solve this equation, first with the initial condition $y_0 = 0$ and then with the initial condition $y_0 = 2$.  The professor wrote on the answer sheet that applying iteratively the recurrence relation it is easy to check that:  $y_k= (1/2)^k y_0 $.  Since I missed the lecture where he explained this, can somebody explain how to come about with this question?  I imagine that once I get the equation, then the initial condition $y_0 = 0$ gives us the particular solution $y_k = 0$. Thus the other initial condition $y_0 = 2$ is verified by the solution $y_k = 2(1/2)^k$.  Any help on how to get to the equation $y_k= (1/2)^k y_0$ will be appreciated. What is the value of $\sum\limits_{i=1}^\infty\frac{1}{p_{p_i}}$ where $p_{i}$ is the $i$th prime? Remember window locations when docked and undocked I find this beyond frustrating.  I have two extra screens on my laptop at work. I take my laptop and go home, with no extra screens connected. I come back, dock the laptop, and the windows need to be rearranged again.  Is there a way to get windows (or a utility) to keep track of the overall screen configuration (#, size, resolution), and remember where windows were placed, so when the screen configuration matches again, it puts applications BACK where they were? I've read a number of the helpful Q&amp;As on photons that mention the mass/mass-less issue. Do I understand correctly that the idea of mass-less (a rest mass of 0) may be just a convention to make the equations work?  From a layperson's view, it's difficult to understand how a particle of light (photon) can be mass-less. A physical object (everyday world-large or quantum-small) must have a mass. Yet, if my understanding is correct, the mass of a moving object/particle increases in proportion to its speed/velocity...so that at the speed of light, its mass would be infinite. A photon travels at the speed of light, but it obviously doesn't have infinite mass, right? Can someone formulate a practical explanation that can be understood by middle-school to high school kids? Much thanks for the help.    Wow--your answers to my original Q below clear up much of my confusion. I now have the daunting task of going over these nuggets and working up an equation-less (hopefully) explanation of the mass-less photon for non-physicist types.  Yes, from a layperson's view, it does seem remarkable that an existing piece of matter-- which has to be made of physical substance--could have zero mass at rest (though a photon is never at rest). It would be almost understandable if a piece of matter made of nothing had zero mass, but that  seems to be an oxymoron, and "nothing" would equate to nonexistent, right?  In case you might find it interesting: I'm working on a writing project that posits we inhabit a universe that consists of matter (physical stuff) only, and that the NON-physical (aka supernatural) does not (and cannot) exist. For instance, if a purported supernatural phenomenon is found to actually exist, then by definition, its existence is proof that it is mundane/natural. All it would take to disprove this premise is reliable proof that ONE supernatural event has occurred. Despite thousands of such claims, that's never yet happened.  Who else better than physicists to confirm my premise? However, I do wish the TV physicists would explain the terms they throw about, some of which mislead/confuse their lay viewers. Case in point: "The universe is made up of matter and energy" (without properly defining the term "energy" as a property of matter).  The result is that laypersons are left with the impression that energy must therefore be something apart from or independent of matter (ie, nonphysical). Their use of the term "pure energy" without specifying exactly what that means adds to the confusion. (Thanks to your replies on this forum, I now understand that "pure energy" refers to photon particles.) However, "psychics" and other charlatans take advantage of such confusion by hijacking terms like energy (as in "psychic energy"), frequencies, vibrations, etc to give perceived scientific legitimacy to their claims that a supernatural spirit world, etc., exists. As you may realize, the majority of people in the US (per 2009 Harris Poll) and around the world believe in the existence of nonphysical/supernatural stuff such as ghosts and spirits.  My purpose is to give laypersons the information they need to distinguish what's real from what's not.  Thanks so much for help...And, PLEASE, add any further comments you think might be helpful/insightful to better inform laypersons. I am trying to remember the title of a children's SF book I once read, maybe 20 to 25 odd years ago.   I don't have a great number of details (and some of what I recall may be completely wrong), but the details (such as they are):   A war between two alien groups ended, and some technology that should have been destroyed was instead imprinted into a human baby. A few years later, both groups find this out and attempt to retrieve it. The main characters are the child, and an alien that I believe was called "Yacob" (or similar) who was sent to protect the child/retrieve the technology, and the antagonists were the other group of aliens that had previously lost the war and were trying to get the technology to start it up again (again, I don't remember the exact details, but I think it was a fairly simple black &amp; white/good vs. bad scenario, being a children's book and all). There was a scene in which Yacob/the alien gives the child blue food, who complains that it's blue, and the alien states "close your eyes and it's just food". The alien had a space shuttle/some other piece of tech disguised as a van. I vaguely recall a scene in which it is under attack and it flies or something. See these three pages:          All three of them say:     Earned at least X total score for at least 20 answers in the  tag.   This same text also appears on the tooltip for the tag badge:   Also note the double colon after 'gold badge'  As well as on these pages:          But the  clearly states:        Bronze Badge:  You must have a total score of 100 in at least 20 non-community wiki answers to achieve this badge.   Silver Badge: You must have a total score of 400 in at least 80 non-community wiki answers to achieve this badge.   Gold Badge: You must have a total score of 1000 in at least 200 non-community wiki answers to achieve this badge.        Edit:  It has been noted in the comments that other users see different numbers in these pages, but in all cases it appears they see the same number of answers are required for all tag badge description, regardless of the badge's type. Can I download and play games from a friend's PSN account on a PS4? Why cant we replace diode connected BJTs by simple diodes in a current mirror circuit? CLI path to ftp network connection I've setup a connectio to an FTP server in Nautilus / Nemo / Caja, the file manager. Now I can browse the contents via this file manager.  How can I browse these files via the command line? What is the path to this network connection? Is this possible, is this a system connection, or specific to the file manager, and do I have to setup a separate FTP connection to do that? If I open this connection in Caja, I see it in Nemo as well, so it seems like a system connection. TZInfo::DataSourceNotFound error starting Rails v4.1.0 server on Windows How do I change NEI to cheat mode? When I heard that you could look up recipes and cheat items with Not Enough Items, I downloaded NEI. It worked, and then I got another mod and the all of a sudden NEI still worked, but it was locked in recipe mode only. I tried fixing it by putting it into cheat mode again, but it was still in recipe mode.  I knew the only reason this happened was probably because of a change in the mod. Then I was watching a YouTuber who had the same exact mod as me and NEI was working and not locked in recipe mode for him. I tried redownloading NEI and getting it again but I was still stuck in recipe mode.  How do I get NEI in cheat mode? my circuit is shown on the picture. the problem is the output of the mosfet does't work as desired. For example, If I use Vin=100V and the duty cycle is 50%, the output is Vout=19V.  Anyway, the output is not even near to the desired value. can you help, please? If the dot product between two vectors is $0$, are the two linearly independent? If we have vectors $V$ and $W$ in $\mathbb{R^n}$ and their dot product is $0$, are the two vectors linearly independent?  I can expand $V_1 \cdot V_2 = 0 \Rightarrow v_1w_1+...+v_nw_n = 0$, but I don't understand how this relates to linear independence. Nested List Indices How can I dynamically load the functions of java.lang.Math Possessive form of coordinated noun phrases? Which of the following is accurate in British English to describe our own wedding?        Alex and Jen's Wedding   Alex's and Jen's Wedding   Alex and Jens' Wedding