Arvutiteaduse instituut
  1. Kursused
  2. 2017/18 kevad
  3. Objektorienteeritud programmeerimine (Narva Kolledž) (P2NC.01.083)
EN
Logi sisse

Objektorienteeritud programmeerimine (Narva Kolledž) 2017/18 kevad

  • Home
  • Materials
  • Java Glossary
  • Source Example
  • Cheat sheet (S1-S6)
  • Grading
  • Links
Session 11

Introduction

In Java, any program is analysed before its execution. Program compilations allow to detect and fix most of the errors; however, some errors occur when the program is running. Some examples:

int[] myNumbers = { 1, 2, 3 };
System.out.println(myNumbers[42]); // ArrayIndexOutOfBoundsException
int n = Integer.parseInt("text"); // NumberFormatException
String myString = null;
myString.length(); // NullPointerException

Runtime errors occur if the JVM detects an operation that is impossible to carry out while a program is running (e.g. try to access an array using an index that is out of bounds - ArrayIndexOutOfBoundsException, use a double value when your program expects an integer - InputMismatchException).

An exception is an object that represents an error or a condition that prevents execution from proceeding normally. If the exception is not handled, the program will terminate abnormally. In other words, an exception is a run-time error. How to handle the exception so that the program can continue to run or else terminate gracefully?

Session 11
  • Arvutiteaduse instituut
  • Loodus- ja täppisteaduste valdkond
  • Tartu Ülikool
Tehniliste probleemide või küsimuste korral kirjuta:

Kursuse sisu ja korralduslike küsimustega pöörduge kursuse korraldajate poole.
Õppematerjalide varalised autoriõigused kuuluvad Tartu Ülikoolile. Õppematerjalide kasutamine on lubatud autoriõiguse seaduses ettenähtud teose vaba kasutamise eesmärkidel ja tingimustel. Õppematerjalide kasutamisel on kasutaja kohustatud viitama õppematerjalide autorile.
Õppematerjalide kasutamine muudel eesmärkidel on lubatud ainult Tartu Ülikooli eelneval kirjalikul nõusolekul.
Courses’i keskkonna kasutustingimused