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
  • Creating Methods
  • Challenge— Write a Cookbook
  1. Intro to Java
  2. Fundimentals of Java

Methods

Methods (known as functions in other coding languages) are blocks of code that someone can easily reuse.

There are two types of methods— instance methods and static methods.

Creating Methods

A method's syntax is this:

[access modifier] [return type] methodName(parameters) {
    [code]
}

Yes. I know this is confusing, especially if you've never touched programming before. Think of a method like a recipe.

A method's access modifier simply tells the code who can access this method. If it's a public, other files can access it. It's like a recipe found on Betty Crocker or something. If it's private, it's a super secret recipe only specific people can access.

The parameters are like the ingredients you need to make the meal. If any of the parameters isn't filled out, the method won't run.

The return type is like the final result of the cookbook.

Challenge— Write a Cookbook

You can tell I'm really creative with this one. All you'll need to do is

PreviousOperationsNextComments

Last updated 2 months ago

🟩