Book Image

Java Fundamentals

By : Gazihan Alankus, Rogério Theodoro de Brito, Basheer Ahamed Fazal, Vinicius Isola, Miles Obare
Book Image

Java Fundamentals

By: Gazihan Alankus, Rogério Theodoro de Brito, Basheer Ahamed Fazal, Vinicius Isola, Miles Obare

Overview of this book

Since its inception, Java has stormed the programming world. Its features and functionalities provide developers with the tools needed to write robust cross-platform applications. Java Fundamentals introduces you to these tools and functionalities that will enable you to create Java programs. The book begins with an introduction to the language, its philosophy, and evolution over time, until the latest release. You'll learn how the javac/java tools work and what Java packages are - the way a Java program is usually organized. Once you are comfortable with this, you'll be introduced to advanced concepts of the language, such as control flow keywords. You'll explore object-oriented programming and the part it plays in making Java what it is. In the concluding chapters, you'll get to grips with classes, typecasting, and interfaces, and understand the use of data structures, arrays, strings, handling exceptions, and creating generics. By the end of this book, you will have learned to write programs, automate tasks, and follow advanced courses on algorithms and data structures or explore more advanced Java courses.
Table of Contents (12 chapters)
Java Fundamentals
Preface

Motivation behind Exceptions


When we are creating programs, we usually focus on expected scenarios. For example, we will get the data from somewhere, we will extract certain information from the data that we assume to be there, we will send it to somewhere else, and so on. We would like our code to be readable, so that members of our team can clearly understand the business logic and can spot mistakes that we may make. However, in practice, our assumptions may not hold and there can be deviations from expected scenarios. For example, we may not be able to get data because of a problem with the network or the disk. We may receive data that does not fit our assumptions. Or, we may not be able to send data because of similar problems. We have to create programs that behave gracefully in unexpected situations. For example: we should enable the user to retry on a broken network connection. Exceptions are the way we handle such situations in Java without making our code too complex.

As programmers...