From the course: Learning Java 11

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Data types and variables in Java

Data types and variables in Java - Java Tutorial

From the course: Learning Java 11

Start my 1-month free trial

Data types and variables in Java

- [Narrator] Let's create some data in Java. In this lesson, we'll be creating a few pieces of data that could represent attributes of a given high school student. Our program will have representations for a students age, GPA, first initial, last initial, as well as if the student has had perfect attendance so far this year. Before we get to the code, let's assign a Java data type to each of these pieces of data. As we mentioned in the last video, an age could be represented in Java with either an int or a double depending on how exact we want to be. In this case, we'll be using an int to represent the age. Potential values for a students GPA could be 3.4 or 2.7 or 4.0. These are all decimal values, so the data type for a students GPA would be double. A students first initial and last initial are each a single character, so both of these would be represented by the data type char. A student can either have perfect attendance or not have perfect attendance, there's no in between. So…

Contents