Imperative programming expresses computation as an ordered list of instructions. Each task runs one at a time, and the program waits for it to finish before continuing. Data must generally be available as a complete unit before the next step processes it. section 11.1
Imperative execution is straightforward, but its sequential model has practical costs:
- A task blocks the executing thread until it completes, especially during I/O such as database writes or remote-server requests. section 11.1
- Adding threads can allow concurrent work, but those threads may also block, making concurrency harder to manage and increasing complexity. section 11.1
- Imperative code remains useful and widely used; reactive programming is an alternative for situations where its model fits better, not a universal replacement. section 11.0 section 11.1
Sequential greeting
A simple imperative program assigns a name, converts it to uppercase, builds a greeting, and prints the result. Each line completes before the next begins. section 11.2
String name = "Craig"; String capitalName = name.toUpperCase(); String greeting = "Hello, " + capitalName + "!"; System.out.println(greeting);
View the complete Java listing for the sequential greeting example. section 11.2













