bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Tutorial
Java•Java Tutorial

Java Data Types Example

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java Data Types Example?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

// ___ variables of different data types int items = 50; float costPerItem = 9.99f; float totalCost = items * costPerItem; char currency = '$'; // Print variables System.out.println("Number of items: " + items); System.out.println("Cost per item: " + costPerItem + currency); System.out.println("Total cost = " + totalCost + currency);

Real-Life Example

Here's a real-life example of using different data types, to calculate and output the total cost of a number of items:

Example

// Create variables of different data types int items = 50; float costPerItem = 9.99f; float totalCost = items * costPerItem; char currency = '$'; // Print variables System.out.println("Number of items: " + items); System.out.println("Cost per item: " + costPerItem + currency); System.out.println("Total cost = " + totalCost + currency);

Previous

Java Characters

Next

Java Non-Primitive Data Types