🇱🇰 Java Enum: Sri Lanka's Provinces with ISO Codes
This Java enum
represents all 9 provinces of Sri Lanka using their official ISO 3166-2:LK codes.
java
public enum SriLankaProvince {
CENTRAL("1"),
EASTERN("2"),
NORTHERN("3"),
NORTH_WESTERN("4"),
SOUTHERN("5"),
WESTERN("6"),
UVA("7"),
SABARAGAMUWA("8"),
NORTH_CENTRAL("9");
private final String code;
SriLankaProvince(String code) {
this.code = code;
}
public String getCode() {
return code;
}
}
Usage Example:
java
SriLankaProvince province = SriLankaProvince.CENTRAL;
System.out.println(province.getCode()); // Outputs: 1
🗃️ SQL Version: Sri Lanka's Provinces Table
Here’s the SQL schema and insert statements for creating a table to represent the provinces of Sri Lanka.
sql
CREATE TABLE sri_lanka_provinces (
id SERIAL PRIMARY KEY,
name VARCHAR(64) NOT NULL,
code CHAR(1) NOT NULL UNIQUE
);
Insert Statements:
sql
INSERT INTO sri_lanka_provinces (name, code) VALUES
('Central', '1'),
('Eastern', '2'),
('Northern', '3'),
('North Western', '4'),
('Southern', '5'),
('Western', '6'),
('Uva', '7'),
('Sabaragamuwa', '8'),
('North Central', '9');
✅ Summary
Representing Sri Lanka’s provinces with Java enums and relational SQL tables ensures consistent handling of regional data. By using ISO 3166-2:LK codes, we maintain international standards and ease of integration across systems.