0

Java documentation says

Field declarations are composed of three components, in order:

  1. Zero or more modifiers, such as public or private.
  2. The field's type.
  3. The field's name.

however, variable declaration in this post has confused me.

private final firstName;
private final lastName;

I cannot understand why there is no dataType for first two variables declared?

Whereas, 3rd and 4th has?

private final Date birthdate;
private final Address address;

Note:Am learning Java, hence to understand if am missing on anything related to variable declaration.

Mihir
  • 95
  • 2
  • 11

2 Answers2

1

That post is incorrect, it should be:

private final String firstName;
private final String lastName;
xingbin
  • 27,410
  • 9
  • 53
  • 103
0

It because he made a mistake forgetting to place a data type on those variable. So it should look like this:

private final String firstName;
private final String lastName; 
Nassir
  • 13
  • 1
  • 6