This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void execute() { | |
RobotContainer.yourSub.printMethod(); | |
//We have to access your subsystem object, stored in RobotContainer | |
//We then call the method you created on that object | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final YourSubsystem yourSub = new YourSubsystem(); | |
//make sure to also import the YourSubsystem class. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MethodChallenge1 { | |
public static void main(String...args) { | |
System.out.println( greater(1,2) ); | |
} | |
public static int greater(int a, int b) { | |
if(a>b) { | |
return a; | |
} else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Point; //Here we import the Point class | |
public class MutabilityDemo { | |
public static void main(String...args) { | |
Point p = new Point(1,1); //We use the Point constructor (using the new keyword) to create a Point object | |
Point p2 = p; //We set a second point equal to the first. | |
p.setLocation(2,2); | |
/* When we put a period next to an object, we are calling a method (in this case setLocation) on that object. | |
The method is part of the Point class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HelloWorld { | |
public static void main(String[] args) { | |
String msg = "Hello World!"; //We initialize the variable here to "Hello World!" | |
System.out.println(msg); //To use the value from the variable, we simply use the variable name, msg | |
} | |
} |