Skip to main content

break Java Keyword


The break keyword is used to prematurely exit a for, while, or do loop or to mark the end of a case block in a
switch statement.
Examples
for (i=0; i<max; i++)
{
if (<loop finished early>)
{
break;
}
}
int type = <some value>;
switch (type)
{
case 1:
<statement>
break;
case 2:
<statement>
break;
default:
<statement>
}

Comments

Popular posts from this blog

Generalization and Specialization

Generalization creates a concept with a broader scope. Specialization creates a concept with a narrower scope. Reusing the interface!  Inheritance: get the interface from the general class. Objects related by inheritance are all of the same type.

Polymorphism and Dynamic Binding

Polymorphism: One piece of code works with all shape objects. Dynamic binding: How polymorphism is implemented Take previous Shape class hierarchy  remove inheritance  remove general and abstract class Shape 

The Object Concept

An object is an encapsulation of data.  An object has identity (a unique reference)  social security number (cpr), employee number, passport number state, also called characteristics (variables)  hungry, sad, drunk, running, alive  behavior (methods) eat, drink, wave, smile, kiss  An object is an instance of an class   A class is often called an Abstract Data Type (ADT).