2

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.

Wortig
  • 963
  • 2
  • 11
  • 37

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
  • 22,334
  • 15
  • 80
  • 130
Lucas Simas
  • 141
  • 1
  • 6
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
  • 6,570
  • 2
  • 30
  • 51