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

Variables and Data Types


One of the fundamental concepts in computer programming is memory, used to store information in the computer. Computers use bits as the smallest information that can be stored. A bit is either a 1 or 0. We can group 8 bits to get what is called a byte. Because bits are very small, we usually deal with bytes as the smallest unit when programming. When we write programs, what we are essentially doing is fetching some bits from a certain memory location, doing some operations on them, and writing back the result to a memory location.

We need a way to store different kinds of data in the computer's memory and tell the computer what kind of data is stored at what memory location.

Data types are a way for us to specify what kind of data and the size we need to store at a given memory location. An example of a data type is an integer, a character, or a string. Broadly, the data types available in Java can be classified into the following types:

  • Primitive data types

  • Reference...