AP CS 2: Static Methods

Premium Lesson

This is a premium course. To view and assign premium course, you must upgrade your account

Upgrade Now

Course Items

Static Methods

A method in Java is a sequence of commands that perform an action.

Passing Data to Methods

Some methods need additional information in order to run. When calling a method, the parenthesis allow us to supply data the method will need.

Passing Exercise

Create a new method named `minutesToHours` that takes an integer amount of minutes and converts it to hours:minutes form.

Return Values

Some methods return data back to the statement where it was called

Multiple Parameters

You can write methods with more than just one parameter for methods which require more than one piece of data.

Planning For Your Trip

Before your drive across the country, it is a good idea to be prepared. Here we'll plan for gas mileage and cost by creating a method

Paying For Gas

Now we can write a void method that will actually subtract the cost of gas from the money we brought with us.

AP CS 2: Static Methods Info

Track

AP Computer Science

Account

MVCode

Rank

Hacker

Created By

jamie

AP CS 2: Static Methods Prereqs