|
Type
|
Description
|
Syntax
|
|
Strings
|
Words
|
" " , Strings |
|
Numbers
|
Numbers
|
int , double |
|
Boolean
|
true or false
|
boolean, true , false |
|
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
|
/*
* 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
*/
// 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);
}
}
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.