#Third question

22 messages ยท Page 1 of 1 (latest)

tender spear
#

how to get rid of null pointer exception thinkLul

storm spearBOT
sly hearth
#

Method 1: Use Kotlin kekw

late quest
#

Method 2:

public static void antiNull(Object a){
   if(a==null) System.exit(0);
}```
#

There. Fixed.

tender spear
#

where is the semicolon ๐Ÿ˜ณ

#

๐Ÿ’€

late quest
#

what are you talking about?

tender spear
#

i see

sly hearth
#

This dude actually thinks he coding in Kotlin ๐Ÿ’€

#

Also, method 3 (more graceful):

void myMethod(Object myArgument) {
  assert myArgument != null;
}
tender spear
#

๐Ÿ—ฟ

brittle cairn
#

Method 3: Use the Optional class

#

it's actually pretty useful ngl

craggy lintel
full swift
#

It is very concise yet expressive

brittle cairn
#

dead lang

full swift
#

shru up

brittle cairn
#

i'm right