​JDK1.8 new feature: still writing null pointer check code repeatedly? Use Optional now

1. Foreword As a Java programmer, whether a novice or a veteran expert, he must have encountered all kinds of abnormal errors. In a foreign article, the ranking list of exception types is counted, as shown in the following figure: Yes, you're right. NullPointerException tops the list. Charles Antony Richard Hoare, the inventor of Null Referen ...

Posted by habs20 on Sat, 21 May 2022 10:20:38 +0300

[Java basics] detailed explanation of methods and technologies in Java Object

Methods in Object Object class is the parent class of all classes. All classes inherit object by default Equals returns true, and hashCode must be the same, so hashCode and equals must be rewritten at the same time (Applied in the Set) equals(Object obj): judge whether the objects are the same To override the equals() method, y ...

Posted by AndyB on Fri, 15 Apr 2022 03:09:08 +0300

Scripting language [basic JavaScript] javascript object, function context and constructor

object There are two kinds of objects in js. Objects in js can dynamically add attributes and methods through point syntax. Narrow object Represented by {}; Narrow objects can have many properties and methods If the property value on the right is function, it is method. The no side is called an attribute. var obj = { ...

Posted by agriz on Thu, 14 Apr 2022 04:17:21 +0300

Three characteristics of object-oriented ---- encapsulation, inheritance and polymorphism

encapsulation The dew should be hidden Programming requires "high cohesion and low coupling" High cohesion means that the internal data operation details of the class are completed by themselves, and external interference is not allowed Low coupling means that only a small amount of methods are exposed for external use. Encapsulati ...

Posted by nomad9 on Wed, 30 Mar 2022 00:53:35 +0300