Revealing a common mistake with Strings 3 – Objects, Immutability, Switch Expressions, and Pattern Matching

WARNING 4! NPE when accessing index value of null array/collection Consider the following code written by a client of ChainSaw: ChainSaw myChainSaw = ChainSaw.initChainSaw(“QWE-T800”);ChainSaw[] friendsChainSaw = new ChainSaw[]{  ChainSaw.initChainSaw(“Q22-T450”),  ChainSaw.initChainSaw(“QRT-T300”),  ChainSaw.initChainSaw(“Q-T900”),  null, // ops!  ChainSaw.initChainSaw(“QMM-T850”), // model is not supported  ChainSaw.initChainSaw(“ASR-T900”)};int score = myChainSaw.performance(friendsChainSaw); Creating an array of ChainSaw was quite challenging in this example. […]

© 2024 nickshade Please read our Terms and Privacy Policy. We also use Cookies.