# Java: Java Programming Idioms

## Introduction

Every programming language has its ways of writing common programming constructions. Sometimes these are used to solve particular problems in a programming language, and other times they are just the "style" that is used in that language.

For example, Java has four equivalent ways to add one to an integer variable:

       i = i + 1;
       i++;
       ++i;
       i += 1;

- Incrementing for loop variable with i++.
- Converting number to string with ""+i
- else if written at same indentation level

introduction | compute compute + output input, compute, output input source screen console (prompt) command line paramters file net device input - read until EOF (test with read vs. test first) hmmm, that sounds like a pattern used by iterators also until count until value input - data representation binary character error detection range checks overflow check (hard) null check input consistency internal consistency tracing error handling (types: data vs programming) reprompt loop stop ignore fix and continue ask give message call error routine throw exception logging ignore - crash or let system handle it
introduction | right column