Skip to main content Accessibility help
Internet Explorer 11 is being discontinued by Microsoft in August 2021. If you have difficulties viewing the site on Internet Explorer 11 we recommend using a different browser such as Microsoft Edge, Google Chrome, Apple Safari or Mozilla Firefox.

Chapter 2: Java Language Basics

Chapter 2: Java Language Basics

pp. 41-145

Authors

, Indian Institute of Technology, Kharagpur, , Indian Institute of Technology, Kharagpur
  • Add bookmark
  • Cite
  • Share

Extract

Any language is characterized by two features: alphabets and grammar. To learn a language, it is necessary to learn these two features first. Once you have learned a language, you will be able to express a thought or idea, such as a poem, in the language. Language is used for communication and Java programming language is not an exception. Java language is used to express a programmer’s instructions to solve a problem just like other programming languages, for example, C, C++, Python, etc. Java looks a lot similar to C++, and, by extension, like C. If you are an experienced C or C++ programmer, this chapter is mostly redundant for you. Java enables a programmer to write robust programs. This chapter aims to teach you all the basic features of Java that a programmer should know.

Introduction

Language elements At this point, we are assuming that you have successfully installed Java and were able to run the sample programs given in Chapter 1. It is time now to start programming. As a Java programmer, it is necessary to have full understanding of the elements of the language like keywords, literals, data types, operators, loops, branches, etc.

Strongly typed language Java programming language mostly follows syntax similar to that of C/ C++ to write statements and expressions. So if you are familiar with C/ C++, it will be easy for you to understand Java. As with all modern programming languages like C/ C++, Java is a strongly typed language, which means all data to be used should be defined their types in programs. Java supports several types of data, which are called primitive data types. In this chapter we will examine several data types, their structures, operations on them, and how they can be utilized to solve problems. Constants and variables are the two basic programming elements. It is necessary to learn how the variables of different data types can be defined. Java has a very good composition of defining arrays of elements of different types, which is also an interesting concept to learn. You may use different data types to declare variables and to create arrays of elements.

About the book

Access options

Review the options below to login to check your access.

Purchase options

eTextbook
US$99.99
Paperback
US$99.99

Have an access code?

To redeem an access code, please log in with your personal login.

If you believe you should have access to this content, please contact your institutional librarian or consult our FAQ page for further information about accessing our content.

Also available to purchase from these educational ebook suppliers