Java Reference
In-Depth Information
public
public class
class
Customer
Customer
{
private
private
int
int
id
;
private
private
String firstName
;
private
private
String lastName
;
private
private
String street
;
private
private
String city
;
private
private
String state
;
private
private
String zip
;
private
private
String country
;
public
public
int
int
getId
() {
return
return
id
; }
public
public
void
void
setId
(
int
int
id
) {
this
this
.
id
=
id
; }
public
public
String
getFirstName
() {
return
return
firstName
; }
public
public
void
void
setFirstName
(
String firstName
) {
this
this
.
firstName
=
firstName
; }
public
public
String
getLastName
() {
return
return
lastName
; }
public
public
void
void
setLastName
(
String lastName
) {
this
this
.
lastName
=
lastName
; }
public
public
String
getStreet
() {
return
return
street
; }
public
public
void
void
setStreet
(
String street
) {
this
this
.
street
=
street
; }
public
public
String
getCity
() {
return
return
city
; }
public
public
void
void
setCity
(
String city
) {
this
this
.
city
=
city
; }
public
public
String
getState
() {
return
return
state
; }
public
public
void
void
setState
(
String state
) {
this
this
.
state
=
state
; }
public
public
String
getZip
() {
return
return
zip
; }
public
public
void
void
setZip
(
String zip
) {
this
this
.
zip
=
zip
; }
public
public
String
getCountry
() {
return
return
country
; }
public
public
void
void
setCountry
(
String country
) {
this
this
.
country
=
country
; }
}
In an Enterprise Java application, the
Customer
class would usually be a Java Persistence
API (JPA) Entity bean and would be used to interact with a relational database. It could also
be annotated with JAXB annotations that allow you to map a Java class directly to XML. To
keep our example simple,
Customer
will be just a plain Java object and stored in memory. In