AP Compupter Science A : Primitive Types
- Olivia J.
- Sep 18, 2023
- 1 min read
By Atina Lee
In the course of AP Computer Science, primitive types or the basic data types of Java are one of the most important lessons you must understand as it is the fundamentals of the language. Here are the 8 primitive types: boolean, byte, character, short, int, long, float, and double. In this blog, we will be focusing on boolean, int, and double.
Booleans
In Java, booleans are a data type that only takes 2 answers: True or False. They are mostly used for comparing items or using conditional testing. In the AP Computer Science A course you will be expected to use booleans to create and write code. Here is some an example of how to declare a boolean:
boolean comparison = True
Int (Integer)/Double
As you may have guessed, Int in Java and many other coding languages stands for integer. Simply said, int are counting numbers while doubles are decimals are floating-point numbers. For this exercise below, identify each number as a double or an int.
3 5.4 3.4 823 .003 300
In Java, you can do a lot with integers and doubles. It is very essential to the curriculum along with the knowledge of booleans. Here is an ending activity for you to practice. How would you add 2 integers together?
Comentarios