Compare double null java




















Skip to content. Change Language. Related Articles. Table of Contents. Improve Article. Save Article. Like Article. Last Updated : 22 Jun, Attention reader! Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.

No need to include some ApacheCommons library for things these days. SimonBaars This isn't running a function on a null object, this is a static method that you pass two arguments, which can be null, or a reference to an object.

I don't want to reinvent the wheel in every single application I write — Neuron. Show 7 more comments. Cat Cat Why not just change the String types to Objects - making it more generic? And then it is the same as what you will get if you move to Java 7. Which java class contains method you provided? Equals is not the same as compare. Compare should be useful for sorting. Eric that doesn't really make it less of a good answer. I am sure you wouldn't argue the best answer is always the one containing only code which is compatible with every java version that has always existed — Neuron.

Show 6 more comments. Neuron 4, 4 4 gold badges 27 27 silver badges 48 48 bronze badges. Luiggi Mendoza Luiggi Mendoza 83k 15 15 gold badges silver badges bronze badges.

Objects is best since Java7, see other answer — tkruse. For those on android, who can't use API 19's Objects. NameSpace NameSpace 9, 3 3 gold badges 37 37 silver badges 39 39 bronze badges. Since version 3. TanvirChowdhury TanvirChowdhury 2, 17 17 silver badges 25 25 bronze badges.

Prashant Sahoo Prashant Sahoo 12 12 silver badges 17 17 bronze badges. You can use java. Objects as following. Vivek 9, 17 17 gold badges 74 74 silver badges bronze badges. Jobi Subramunian Jobi Subramunian 7 7 bronze badges. This case returns false if both Strings are null which might not be the desired result.

Last Updated : 19 Jun, Attention reader! Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. Previous Java long compareTo with examples. Next Double compare Method in Java with Examples. Recommended Articles. Article Contributed By :. Twinkl Bajaj. Easy Normal Medium Hard Expert.

Writing code in comment? Please use ide.



0コメント

  • 1000 / 1000