Intro to FRC Programming - Romi
  • INTRODUCTION
    • Overview
    • Important Links
  • 💽Setup
    • Setting up the Romi's Software
    • Downloading Essential Tools
    • APCS vs FRC
  • How To Code in VSC
    • VSC- Intro
    • A Tour Through VSC
    • Creating a Regular Java Project
  • Intro to Java
    • What is Java?
    • Beginning Steps
    • 🟩Fundimentals of Java
      • Variables
      • Operations
      • Methods
      • Comments
      • If Statements and Conditions
      • Boolean Zen
      • Loops
      • Challenge- Create a Box House
    • 🟨Advanced Concepts
      • Objects
      • Scanners
      • Null Objects
      • Arrays
      • Errors
      • For-Each Loops
    • 🟥Object Oriented Programming
      • Basics of OOP
      • Instance Classes
      • Static Classes
  • 🕑Romi Curriculum- Timed Base
    • Romi Curriculum- Introduction
    • Creating a WPILIB Project
    • Running Your Code
    • The Robot Class
    • Subsystems
      • RomiDrivetrain
    • Cool stuff i will rename this category later
      • Spark Motors
      • PIDs
      • External Controllers
      • Encoders
  • 🖥️Romi Curriculum- Command Based
    • Command Based Code
    • RobotContainer
    • Commands
    • CommandScheduler
  • UNRELATED IMPORTANT CODING KNOWLEDGE
    • Constants
  • SAMPLE CODE
    • Tank Drive Example
      • RobotContainer
      • TankDriveSubsystem
      • MoveRobotCommand
    • Worktop Systems Sample Java Code
      • Belt Elevator Sample Code
      • Rotating Arm Sample Code
Powered by GitBook
On this page
  • Math Operations
  • Unary Operations
  • Logic Operators
  1. Intro to Java
  2. Fundimentals of Java

Operations

What if you wanted to do some math in your code? Or check if a certain condition is true? You can use operators!

There are multiple types of operations,

Note for simplicity's sake, some operators will be placed where they're most relevant (ex: logic operators around if-statements)

Math Operations

These are used to do math with data.

Operator
Purpose
Syntax

Addition

Adds two numbers.

a + b

Subtraction

Subtracts two numbers.

a - b

Multiplication

Multiplies two numbers.

a * b

Division

Divides two numbers.

a / b

Modulus

Divides two numbers, but gets the remainder.

a % b

Unary Operations

These are used to modify variables.

Unary Operator
Purpose
Example

+=

Adds n to the variable.

num += 3

-=

Subtracts n from the variable.

num -= 16

*=

Multiplies the variable by n.

num *= 3

/=

Divides the variable by n.

num /= 10

Logic Operators

Logic operators compare values, letting you do logic as the name suggests. For here, you'd use them with if-statements, which we'll cover soon.

Logic Operator
Syntax
Purpose
Example

== (Equals)

value == value

Checks if the two values are equal.

true == true // returns true 1 == 1 // returns true 6 == 9 // returns false

!= (Not equals)

value != value

Returns if the two values are NOT equal.

true != false // returns true 2 != 2 // returns false

&& (And)

condition && condition

Checks if both of the conditions are true.

true && true // returns true

2 == 4 // returns false

|| (Or)

condition || condition

Gives you if one of the conditions is true.

1 == 2 || 3 > 2 // returns true because 3 > 2

! (Not)

!condition

Gives you if the condition is false.

!(2 == 4) // returns true !(3 == 3) // returns false

PreviousVariablesNextMethods

Last updated 2 months ago

🟩