Java Cheat Sheet
Java Cheat Sheet
String Methods
(assume stringVariable is name) Java Escape Characters
\n new line – position cursor to the beginning of next line
length stringVariable.length();
\t horizontal tab
equals stringVariable.equals(otherStringVariable);
\r position cursor to beginning of current line
stringVariable.equalsIgnoreCase(otherStringVariable);
\\ backslash – prints a backslash
lowercase stringVariable.toLowerCase();
\” prints a double quote
uppercase stringVariable.toUpperCase();
trim stringVariable.trim()
System.out.println("Hello\nnext\nLine");
charAt(Position) stringvariable.charAt(Position);
class Box
{
private double width, height, length;
//constructors
Box( double W, double H, double L)
{ height = H ;
width = W ; Input with EasyReader
length = L ;
} // console is an EasyReader Object you create below
// methods EasyReader console = new EasyReader();
double volume()
{ //EasyReader Method Calls are below
return length*width*height ; change = console.readInt();
} discountRate = console.readDouble();