Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views2 pages

Mathematical Functions, Characters, and Strings

Chapter 4 discusses mathematical functions available in Java's Math class, including sin, cos, and random, as well as character handling with the char type and the Character class methods. It explains string manipulation, including methods for obtaining string length, concatenation, and comparison. Additionally, it covers the use of escape sequences and formatted output with the printf method.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Mathematical Functions, Characters, and Strings

Chapter 4 discusses mathematical functions available in Java's Math class, including sin, cos, and random, as well as character handling with the char type and the Character class methods. It explains string manipulation, including methods for obtaining string length, concatenation, and comparison. Additionally, it covers the use of escape sequences and formatted output with the printf method.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CHAPTER 4 SUMMARY

MATHEMATICAL FUNCTIONS, CHARACTERS, AND STRINGS

Java provides the mathematical methods sin, cos, tan, asin, acos, atan, toRadians,
toDegree, exp, log, log10, pow, sqrt, ceil, floor, rint, round, min, max, abs, and
random in the Math class for performing mathematical functions.

The character type char represents a single character.

An escape sequence consists of a backslash (\) followed by a character or a combination of


digits.

The character \ is called the escape character.

The characters ' ', \t, \f, \r, and \n are known as the whitespace characters.

Characters can be compared based on their Unicode using the relational operators.

The Character class contains the methods isDigit, isLetter, isLetterOrDigit, isLowerCase,
and isUpperCase for testing whether a character is a digit, letter, lowercase, or uppercase. It
also contains the toLowerCase and toUpperCase methods for returning a lowercase or
uppercase letter.
A string is a sequence of characters. A string value is enclosed in matching double quotes ("). A
character value is enclosed in matching single quotes (').

Strings are objects in Java. A method that can only be invoked from a specific object is called an
instance method. A non-instance method is called a static method, which can be invoked
without using an object.

You can get the length of a string by invoking its length() method, retrieve a character at the
specified index in the string using the charAt(index) method, and use the indexOf and
lastIndexOf methods to find a character or a substring in a string.

You can use the concat method to concatenate two strings, or the plus (+) operator to
concatenate two or more strings.

You can use the substring method to obtain a substring from the string.

You can use the equals and compareTo methods to compare strings. The equals method
returns true if two strings are equal, and false if they are not equal. The compareTo method
returns 0, a positive integer, or a negative integer, depending on whether one string is equal to,
greater than, or less than the other string.

The printf method can be used to display a formatted output using format specifiers.

You might also like