Dave Drohan (SETU)

BACK NEXT

Primitive Data Types

In Java, there are:

Using the int data type

Create a new Sketchbook in your PDE and save it using the following naming convention: labXX_stepYY, where XX is the number of the lab and YY is the number of the step.

Enter the following code: Using int data type to set the coordinates of three lines Run the code. Your window should now have three blue lines similar to the screen shot below: Three blue linesUpdate the code using a, b and c variables to generate new lines:

Using int data type to set the coordinates of more lines

Run the code. Your window should now have three new blue lines similar to the screen shot below:

Six blue lines

A syntax error

Update the code by changing int to Int (uppercase I). Run your code again. What happened? Can you explain what happened? Ask your lecturer to explain it if you are not sure.

Change Int back to int.

Another syntax error

Update the code by changing the amount assigned to variable a from 70 to 70.56.

Run your code again. What happened? Can you explain what happened? Ask your lecturer to explain it if you are not sure.

Change 70.56 back to 70.

Save and close the sketchbook.