In today's episode of ByteSized, we are looking at a nice trick to avoid null pointer exceptions: Meet the Yoda Condition, also known as Yoda Comparison or Yoda Style. The idea simply is to flip around (swap) the arguments in a comparison, such that the constant argument is first, to eliminate the option that it can take `null` as its value.
This trick is specifically useful in Java, but works in pretty much any programming language that has a `null` value.
#Java #Null #Nullability #Tutorial #Guide #Shorts
If you have any suggestions for content or feedback please leave them in the comments.
In case you enjoyed this video, make sure to leave like, subscribe and share it with anyone you could consider interested!