Reputation: 95
Field declarations are composed of three components, in order:
- Zero or more modifiers, such as public or private.
- The field's type.
- 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.
Upvotes: 0
Views: 65
Reputation: 28269
That post is incorrect, it should be:
private final String firstName;
private final String lastName;
Upvotes: 1
Reputation: 13
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;
Upvotes: 0