1

Is there a nullable data type in java like int?, char?... in C#? Is there a way to create it as a class or something?

Need to create data type which will be able to hold null as well as number values.

MickyD
  • 14,343
  • 6
  • 43
  • 67
Wortig
  • 672
  • 9
  • 24

2 Answers2

1
  • int is not nullable in Java
  • But Integer is a class that contains a abstraction for int and can be null
MC Emperor
  • 20,870
  • 14
  • 76
  • 119
Lucas Simas
  • 131
  • 1
  • 5
1

You could use Integer since its nullable;

https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html

The same goes for Boolean.

basically they're class wrappers over the primitive types.

sommmen
  • 4,642
  • 1
  • 16
  • 33