Hi
I have just started my SCJD Coursework, I have been assigned a variety of Bodgitt and Scarper. :-)
In the Coursework Database Schema specification it states the length of each field in bytes, for example from B&S coursework:
Field Descriptive Name | Database Field Name | Field length
-----------------------|---------------------|--------------
Subcontractor Name | name | 32
City | location | 64
So in a setter for the Subcontractor name above would the length check be
OPTION 1:
if(name.length > 64 || name.length = 0)
{
throw IllegalArgumentException("error message etc")
}
or
OPTION 2:
if(name.getBytes("US-ASCII").length > 64 || name.length = 0)
{
throw IllegalArgumentException("error message etc")
}
I am quite certain that OPTION2 is the correct check however I thought I would see what the wise SCJD forum thinks?
Thanks if advance.
Simon
I have just started my SCJD Coursework, I have been assigned a variety of Bodgitt and Scarper. :-)
In the Coursework Database Schema specification it states the length of each field in bytes, for example from B&S coursework:
Field Descriptive Name | Database Field Name | Field length
-----------------------|---------------------|--------------
Subcontractor Name | name | 32
City | location | 64
So in a setter for the Subcontractor name above would the length check be
OPTION 1:
if(name.length > 64 || name.length = 0)
{
throw IllegalArgumentException("error message etc")
}
or
OPTION 2:
if(name.getBytes("US-ASCII").length > 64 || name.length = 0)
{
throw IllegalArgumentException("error message etc")
}
I am quite certain that OPTION2 is the correct check however I thought I would see what the wise SCJD forum thinks?
Thanks if advance.
Simon