I want to convert a web form to a model in Java.
In C# I can write this:
public class Test
{
You can use an Integer
, which is a reference type (class)in Java and therefore nullable.
Int32
(or int
) is a struct (value type) in C#. In contrast, Integer
in Java is a class which wraps an int
. Instances of reference types can be null
, which makes Integer
an legit option.
Nullable
in .NET gives you similar options because it enables you to treat a value type like a nullable type. However, it's still different from Java's Integer
since it's implemented as a struct (value type) which can be compared to null
, but cannot actually hold a genuine null reference.