error classes - Slides 2/1 COP 3330 Topics • Java Basics...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Slides 2/1 COP 3330 Topics • Java Basics: String methods, math methods, errors • Classes and objects String Methods • Java Strings are immutable. That means that once they're created, they can't be altered • Calling methods on Strings will return new Strings, but leave the original intact String Methods • These are instance methods (that means they're called on String objects)- concat() : Takes in a String and returns a new String. Equivalent to +- replace() : Takes in two chars and returns a new String. The first char is the character to be replaced, and the second char is the character to replace it with String Methods • More methods- substring() : Takes in two ints and returns a new String. The first int is the beginning index and the second int is the ending index of the substring- length() : Takes in no parameters. Returns the length of the String- charAt() : Takes in an int and returns the character at that index Math Methods • These are static methods. That means they are called on the Math class (it doesn't make sense to have a Math object)- abs() : Takes in an int and returns its absolute value- sin(), cos(), tan() : Take in doubles and perform trigonometry. These functions use radians, not degrees Math Methods • More Math methods- pow() : Takes in two doubles and returns the first raised to the power of the second- random() : Takes in no parameters and returns a random double in the range from 0.0 to 1.0, including 0, but excluding 1....
View Full Document

{[ snackBarMessage ]}

Page1 / 31

error classes - Slides 2/1 COP 3330 Topics • Java Basics...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online