Don't Blink LogoFTC Stack

The Basics

Variables, data types, operators, printing, and comments.

Basics

Every Java program is built from a few fundamental concepts.

Variables

Variables store information.

int score = 10;
String teamName = "Don't Blink";

You can change the value later.

score = 15;

Data Types

Every variable has a type.

TypeExampleDescription
int5Whole numbers
double3.14Decimal numbers
booleantrueTrue or false
char'A'Single character
String"FTC"Text
int motors = 4;
double power = 0.75;
boolean intakeRunning = true;
String robotName = "Don't Blink";

Operators

Arithmetic operators perform math.

OperatorDescriptionExampleResult
+Addition5 + 38
-Subtraction5 - 32
*Multiplication5 * 315
/Division6 / 23
%Modulus (Remainder)7 % 31

Assignment operators update variables.

OperatorDescriptionExample
=Assignmentx = 5
+=Add and assignx += 2
-=Subtract and assignx -= 2
*=Multiply and assignx *= 2
/=Divide and assignx /= 2
%=Modulus and assignx %= 2
++Increment by 1x++
--Decrement by 1x--

Comparison operators compare values.

OperatorDescriptionExample
==Equal tox == 5
!=Not equal tox != 5
>Greater thanx > 5
<Less thanx < 5
>=Greater than or equal tox >= 5
<=Less than or equal tox <= 5

Logical operators combine conditions.

OperatorDescriptionExample
&&Logical ANDx > 0 && y > 0
||Logical ORx > 0 || y > 0
!Logical NOT!isRunning

Printing

You can print information to the console.

System.out.println("Hello!");

In FTC, you'll usually use telemetry instead.

telemetry.addData("Power", power);
telemetry.update();

Comments

Comments explain your code.

Single-line comment:

// Drive forward

Multi-line comment:

/*
This code controls
the intake.
*/

Comments are ignored when your program runs.

Key Takeaways

  • Variables store data.
  • Every variable has a type.
  • Operators perform calculations and comparisons.
  • System.out.println() prints text.
  • Comments help explain your code.

Was this resource helpful?

On this page

Was this resource helpful?