Error handling
- Programs are subject to "errors", e.g. bad index in an array, read a file that does not exists, etc.
As a example, let's consider a Catalog
of Products
below.
What is the problem with the result ?
public static void main(String[] args) {
Catalog bookstore = new Catalog();
// Product(name,price,quantity)
bookstore.add(new Product("Core Java", 52.29, 13));
bookstore.add(new Product("FP in Java", 41.63, 8));
bookstore.buy("Core Java", 30);
System.out.println(bookstore);
}
Product | Qty | Price
---------------------------------------------------
Core Java | -17 | 52.29 euros
FP in Java | 8 | 41.63 euros
1 - 12Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented