FTC Programming

Variables and Object Types

Learn the types of objects and variables you will use in FTC.

Basic Types

While there are numerous variable types in Java, here are the 5 most critical ones used in FTC.
  • int
  • float
  • double
  • string
  • boolean

What is a int?

The int variable holds a numerical value that can be accessed when called upon. It can hold integers or whole numbers.

 int inchCount;
 inchCount = 6; 

What is a float?

The float variable is used to represent numbers that have a decimal place in them. It is similar to the int variable type, but can hold up to 7 digits of precision.

float decimal = (float) 3.2; float d = 3.2f;

What is a double?

The double variable is more precise than the float variable type because this type of variable can hold up to 16 digits of precision.

 double numeral = 5.6;
 numeral = 2.4; 

What is a string?

A string variable is used to show a line of text, numbers, or symbols. String message1 = new String("This is how to write a string!"); String message2 = "Wow this is amazing!";

What is a boolean?

A boolean variable basically tells if an instance is true or false. For example, if one action is deemed true, then it will carry out a specific action.

 boolean value = true;
 
 if (value == true) {
 	System.out.println("this is true");
 }
 else {
 	System.out.println("this is false");
 } 
chevron_up