Moving beyond single variables — this subtopic introduces arrays, the first real 'data structure' of the syllabus.
Date/time handling — using built-in classes/methods provided by the programming language to input, validate, store and output dates and times correctly (rather than as plain strings).
String manipulation methods you should be comfortable with: isolating individual characters, comparing strings, counting characters, inserting, replacing, appending, and deleting characters within a string (see 11.4.8 for applied algorithms).
| Comparison | Parallel arrays | Array of objects |
|---|---|---|
| Data cohesion | Related data is spread across multiple separate arrays — easy to accidentally get out of sync | Related data for one entity is bundled together in a single object — much harder to desynchronise |
| OOP alignment | Not object-oriented | Reflects real OOP design and encapsulation |
| When preferred | Simple scripts with limited related fields | Any realistic program modelling real-world entities |
Example
// Parallel arrays String[] names = {"Ana", "Ben"}; int[] ages = {17, 18}; // Array of objects (preferred in OOP) Learner[] learners = new Learner[2]; learners[0] = new Learner("Ana", 17); learners[1] = new Learner("Ben", 18);
Sorting, searching and array manipulation algorithms are covered in detail in 11.4.8.
💡 Exam Tip
Exam questions almost always prefer 'array of objects' as the recommended design over parallel arrays when modelling real entities — be ready to explain why (data stays together, reduces the risk of arrays becoming out of sync).