Searching for: Blocks in Java
Try Catch Block
A try-catch block is used to mitigate errors in code and prevent program crashing during runtime. It 'tries' a block of code that could give an error. If the error (exception) is caught, it will execute a different block of code rather than crash the program.
The while loop executes a block of code while a boolean expression evaluates to true. It terminates as soon as the expression evaluates to false. The boolean expression is evaluated before each iteration.
Commenting is used to write text within the code that is ignored by the compiler.
Class methods are methods that are called on the class itself, not on a specific object instance. The static modifier ensures implementation is the same across all class instances. Many standard built-in classes in Java (for example, Math) come with static methods (for example, Math.abs(int value)) that are used in many Java programs.
Next Page >