Cheatography
https://cheatography.com
Data
Type |
Description |
Syntax |
Strings |
Words |
|
Numbers |
Numbers |
|
Boolean |
true or false |
|
All of the Syntax column is case sensitive
Information is data with context
Useful methods and operations
Method |
Description |
throw new IllegalArgumentException(String);
|
used to show an error |
Integer.toString(i) and Double.toString(i)
|
takes and int or a double and makes them strings |
"String".equals(" String")
|
checks if two strings are equal |
Example Template
/*
* Fields:
* this.x, this.y, this.radius
*
* Methods:
* this.sameShape(IShape) -> boolean
* this.sameCircle(Circle) -> boolean
*
* Methods on fields:
*
* Fields of parameters:
*
* Methods on parameters:
* that.sameShape(IShape) -> boolean
*/
|
|
|
Abstracts and Subclass
// Interface for a Shape
interface IShape {
}
// Abstract of a Shape
abstract class AShape implements IShape {
String color;
AShape(String color) {
this.color = color;
}
}
// to represent a rectangle
class Rect extends AShape {
int width;
int height;
Rect(int width, int height, String color) {
super(color);
this.width = width;
this.height = height;
}
}
// Subclass square that extends Rectangle
class Square extends Rect {
Square(int size, String color) {
super(size, size, color);
}
}
|
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets