|
Generated by JDiff |
||||||||
PREV PACKAGE NEXT PACKAGE FRAMES NO FRAMES |
This file contains all the changes in documentation in the packagejava.lang
as colored differences. Deletions are shownlike this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.
Thrown when an application tries to call an abstract method. Normally this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled. @author unascribed @version 1.15 0216 12/0203/0001 @since JDK1.0
Thrown when an exceptional arithmetic condition has occurred. For example an integer "divide by zero" throws an instance of this class. @author unascribed @version 1.19 0220 12/0203/0001 @since JDK1.0
Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array. @author unascribed @version 1.18 0219 12/0203/0001 @since JDK1.0
Thrown to indicate that an attempt has been made to store the wrong type of object into an array of objects. For example the following code generates anArrayStoreException
:@author unascribed @version 1.Object x[] = new String[3]; x[0] = new Integer(0);8 029 12/0203/0001 @since JDK1.0
The Boolean class wraps a value of the primitive typeClass Boolean, constructor Boolean(boolean)boolean
in an object. An object of typeBoolean
contains a single field whose type isboolean
.In addition this class provides many methods for converting a
boolean
to aString
and aString
to aboolean
as well as other constants and methods useful when dealing with aboolean
. @author Arthur van Hoff @version 1.38 0242 12/0203/0001 @since JDK1.0
Allocates aBoolean
object representing thevalue
argument.Note: It is rarely appropriate to use this constructor. Unless a new instance is required the static factory #valueOf(boolean) is generally a better choice. It is likely to yield significantly better space and time performance. @param value the value of the
Boolean
.
TheClass Byte, constructor Byte(String)Byte
class wraps a value of primitive typebyte
in an object. An object of typeByte
contains a single field whose type isthebyte
.In addition
standardthiswrapperclass provides several methods for converting abyte
to aString
and aString
to abyte as well as other constants and
valuesmethods useful when dealing with abyte
. @author Nakul Saraiya @version 1.20 0228 12/0203/0001 @see java.lang.Number @since JDK1.1
Constructs a newly allocatedClass Byte, constructor Byte(byte)Byte object
initialized tothat represents thebyte
valuespecifiedindicated by theString
parameter. Theradixstring isassumedconverted tobeabyte
value in exactly the manner used by theparseByte
method for radix 10. @param s theString
to be converted to aByte
@exception NumberFormatException If theString
does not contain a parsablebyte
. @see java.lang.Byte#parseByte(java.lang.String int)
Constructs a newly allocatedClass Byte, byte byteValue()Byte object
initialized tothat represents the specifiedbyte
value. @param value theinitialvalueofto be represented by theByte
.
Returns the value of thisClass Byte, int compareTo(Byte)Byte
as abyte
.
Compares twoClass Byte, int compareTo(Object)BytesByte
objects numerically. @param anotherByte theByte
to be compared. @return the value0
ifthe argumentthisByte
is equal tothisthe argumentByte; a value less than
0
if thisByte
is numerically less than theByteargumentByte
; and a value greater than0
if thisByte
is numerically greater than theByteargumentByte
(signed comparison). @since 1.2
Compares thisClass Byte, Byte decode(String)Byte
object to anotherObjectobject. If theObjectobject is aByte
this function behaves likecompareTo(Byte)
. Otherwise it throws aClassCastException
(asBytesByte
objects arecomparableonly comparable to otherBytesByte
objects). @param o theObject
to be compared. @return the value0
if the argument is aByte
numerically equal to thisByte
; a value less than0
if the argument is aByte
numerically greater than thisByte
; and a value greater than0
if the argument is aByte
numerically less than thisByte
. @exceptionClassCastException
if the argument is not a. @see java.lang.Comparable @since 1.2
Byte
Decodes aClass Byte, double doubleValue()String
into aByte
. Accepts decimal hexadecimal and octal numbersingiven by the followingformatsgrammar:[-]DecimalNumeral HexDigits and OctalDigits are defined in §3.10.1 ofdecimal
constant- DecodableString:
[-]- Signopt DecimalNumeral
- Signopt
0x
hexHexDigits- Signopt
constant0X
[-]HexDigits- Signopt
#
HexDigits- Signopt
hex0
constantOctalDigits
- Sign:
[-
] 0octalconstantthe Java Language Specification.The
constantsequence of characters following an (optional) negative sign and/or"radix specifier"("0x
" "0X
" "#
" or leading zero) is parsed as by theByte.parseByte
method with thespecifiedindicated radix (10816 or168). Thisconstantsequence of characters mustberepresent a positive value or a NumberFormatException willresultbe thrown. The result ismadenegatednegativeif first character of the specifiedString
is thenegativeminus sign. No whitespace characters are permitted in theString
. @param nm theString
to decode. @returntheaByte
represented byobject holding thespecifiedbyte
string.value represented bynm
@exception NumberFormatException if theString
does not contain a parsablebyte
. @see java.lang.Byte#parseByte(java.lang.String int)
Returns the value of thisClass Byte, boolean equals(Object)Byte
as adouble
.
Compares this object to the specified object. The result isClass Byte, float floatValue()true
if and only if the argument is notnull
and is aByte
object that contains the samebyte
value as this object. @param obj the object to compare with @returntrue
if the objects are the same;false
otherwise.
Returns the value of thisClass Byte, int hashCode()Byte
as afloat
.
Returns aClass Byte, int intValue()hashcodehash code for thisByte
.
Returns the value of thisClass Byte, long longValue()Byte
as anint
.
Returns the value of thisClass Byte, byte parseByte(String)Byte
as along
.
Class Byte, byte parseByte(String, int)AssumingParses thespecifiedstringString representsargument as a signed decimalbyte.
returns thatThe charactersbyte'sinvalue.theThrows an exceptionstring must allifbe decimal digits except that theStringfirst charactercannotmay beparsedanasASCII minus sign'-'
('\u002D'
) to indicate abytenegative value. Theradixresultingbyte
value isassumed toreturned exactlybeas if the argument and the radix 10 were given as arguments to the int) method. @param stheaString
containing thebyte
representation to be parsed @return theparsedbyte
valueofrepresented by thebyteargument in decimal @exception NumberFormatExceptionIfif the the string does not contain a parsablebyte
.
Class Byte, short shortValue()AssumingParses thespecifiedstringString representsargument as a signedbyte in the radix specified by the second argument. The characters in the string must all be digits of the specified radix (as determined by whether int) returns a nonnegative value) except that
bytethe first character may be an ASCII minus sign'
s-' ('\u002D'
) to indicate a negative value.ThrowsTheanresultingbyte
value is returned.An
exception of typeNumberFormatException
is thrown if any of theStringfollowing situations occurs:
- The first argument is
null
or is a string of length zero.cannotThe radix is either smaller than java.lang.Character#MIN_RADIX or larger than java.lang.Character#MAX_RADIX Any character of the string is not a digit of the specified radix except that the first character may beparsedaasminus sign'-'
('\u002D'
) provided that the string is longer than length 1.The value represented by the string is not a value of typebyte. @param s the
String
containing thebyte
representation to be parsed @param radix the radix to be used while parsings
@return theparsedbyte
valueofrepresented by thebytestring argument in the specified radix @exception NumberFormatException If theStringstring does not contain a parsablebyte
.
Returns the value of thisClass Byte, String toString()Byte
as ashort
.
Returns aClass Byte, String toString(byte)String
object representing thisByte
's value. The value is converted to signed decimal representation and returned as a string exactly as if thebyte
value were given as an argument to the java.lang.Byte#toString(byte) method. @return a string representation of the value of this object in base 10.
Returns a newClass Byte, Byte valueOf(String)String
object representing the specifiedBytebyte
. The radix is assumed to be 10. @param b thebyte
to be converted @return the string representation of the specifiedbyte
@see java.lang.Integer#toString(int)
@param s theAssumingReturns aByte
object holding the value given by the specifiedString
.represents a byte returnsThe argument is interpreted as representing anew Bytesigned decimalobjectbyte
initialized to thatexactly as ifvalue.theThrows an exception ifargument were given to the #parseByte(java.lang.String)cannotmethod.be parsed asThe result is aByte
object that represents thebyte
value specified by the string.The radixIn
isother words this methodassumedreturns aByte
object equal tobethe value of:new
10Byte(Byte.parseByte(s))
Byte
String
does not contain a parsable byte
.
Class Byte, Byte valueOf(String, int)Class Byte, byte MAX_VALUEAssumingReturns aByte
object holding the value extracted from the specifiedString
representswhen parsed with the radix given by the second argument. The first argument is interpreted as representing a signedbyte
returns a new Bytein the radix specifiedobjectby the second argument exactly as if theinitializedargument were given tothatthevalueint) method.Throws an exceptionThe result isifaByte
object that represents theStringbyte
cannot be parsedvalue specified byasthe string.In other words this method returns a
byteByte
object equal to the value of:@param s thenew Byte(Byte.parseByte(s radix))
String containing the integerstring to be parsed @param radix the radix to be used in interpretings
@returntheaByte
instanceobjectrepresentingholding theparsedvaluebyterepresentedvalueby the string argument in the specified radix. @exception NumberFormatException If theString
does not contain a parsablebyte
.
Class Byte, byte MIN_VALUETheA constant holding the maximum value aBytebyte
can have 27-1.
Class Byte, Class TYPETheA constant holding the minimum value aBytebyte
can have -27.
TheClass
objectinstance representing the primitive typebyte
.
TheCharacter
class wraps a value of the primitive typechar
in an object. An object of typeCharacter
contains a single field whose type ischar
.In addition this class provides several methods for determining
theatypecharacter'sofcategorya(lowercasecharacterletter digit etc.) and for converting characters from uppercase to lowercase and vice versa.
ManyCharacterofinformation is based on the Unicode Standard version 3.0.The
methods and data of classCharacter
are definedin terms of aby the information in"UnicodetheattributeUnicodeDatatable"file thatspecifies a nameisfor every definedpart of the UnicodecodeCharacterpoint.DatabaseThe table also includesmaintained by the UnicodeotherConsortium.attributes such as a decimal value an uppercase equivalent a lowercase equivalentThis file specifies various properties including name and general category for everyand/ordefineda titlecaseUnicode codeequivalent.pointTheor characterattributerange.tables for specific versions of UnicodeThe file and its description are available
onfrom theWorld Wide Web in variousUnicodesubdirectories ofConsortium at:Joy and Steele The Java Language Specification.@author Lee Boynton @author Guy Steele @author Akira Tanaka @version 1.61 02/02/00 @sinceJDK11.0
Constructs a newClass Character.Subset, boolean equals(Object)Subset
instance. @exception NullPointerException if name isnull
@param name The name of this subset
Compares twoClass Character.Subset, int hashCode()Subset
objects for equality. This method returnstrue
if and only ifand
xthisythe argument refer to the same object;and because itsince this method isfinal
it guarantees thisthis guarantee holds for all subclasses.
Returns the standard hash code as defined by the{@link Object#hashCode}
method. This method isfinal
in order to ensure that theequals
andhashCode
methods will be consistent in all subclasses.
A family of character subsets representing the character blocksdefinedinbythe Unicode2.0specification.AnyCharacter blocks generally define charactersgivenused for a specific script or purpose. A character is contained by at most one Unicode block. @since 1.2
Constructs a newly allocatedClass Character, char charValue()Character
objectand initializes it sothatitrepresents theprimitivespecified
valuecharargumentvalue. @param value the valuefor theto benewrepresented by theCharacter
object.
Returns the value of thisClass Character, int compareTo(Character)Character
object. @return the primitivechar
value represented by this object.
Compares twoClass Character, int compareTo(Object)CharactersCharacter
objects numerically. @param anotherCharacter theCharacter
to be compared. @return the value0
if the argumentCharacter
is equal to thisCharacter
; a value less than0
if thisCharacter
is numerically less than theCharacter
argument; and a value greater than0
if thisCharacter
is numerically greater than theCharacter
argument (unsigned comparison). Note that this is strictly a numerical comparison; it is not locale-dependent. @since 1.2
Compares thisClass Character, int digit(char, int)Character
object to anotherObjectobject. If theObjectobject is aCharacter
this function behaves likecompareTo(Character)
. Otherwise it throws aClassCastException
(asCharactersCharacter
objects are comparable only to otherCharactersCharacter
objects). @param o theObject
to be compared. @return the value0
if the argument is aCharacter
numerically equal to thisCharacter
; a value less than0
if the argument is aCharacter
numerically greater than thisCharacter
; and a value greater than0
if the argument is aCharacter
numerically less than thisCharacter
. @exceptionClassCastException
if the argument is not aCharacter
. @see java.lang.Comparable @since 1.2
Returns the numeric value of the characterClass Character, char forDigit(int, int)ch
in the specified radix.If the radix is not in the range
MIN_RADIX
<=radix
<=MAX_RADIX
or if the value ofch
is not a valid digit in the specified radix-1
is returned. A character is a valid digit if at least one of the following is true:@param ch the character to be converted. @param radix the radix. @return the numeric value represented by the character in the specified radix. @see java.lang.Character#forDigit(int int) @see java.lang.Character#isDigit(char)
- The method
isDigit
istrue
of the character and the Unicode decimal digit value of the character (or its single-character decomposition) is less than the specified radix. In this case the decimal digit value is returned.- The character is one of the uppercase Latin letters
'A'
through'Z'
and its code is less thanradix + 'A' - 10
. In this casech - 'A' + 10
is returned.- The character is one of the lowercase Latin letters
'a'
through'z'
and its code is less thanradix + 'a' - 10
. In this casech - 'a' + 10
is returned.
Determines the character representation for a specific digit in the specified radix. If the value ofClass Character, int getNumericValue(char)radix
is not a valid radix or the value ofdigit
is not a valid digit in the specified radix the null character ('\u0000'
) is returned.The
radix
argument is valid if it is greater than or equal toMIN_RADIX
and less than or equal toMAX_RADIX
. Thedigit
argument is valid if0 <=
.digit <=radixIf the digit is less than 10 then
'0' + digit
is returned. Otherwise the value'a' + digit - 10
is returned. @param digit the number to convert to a character. @param radix the radix. @return thechar
representation of the specified digit in the specified radix. @see java.lang.Character#MIN_RADIX @see java.lang.Character#MAX_RADIX @see java.lang.Character#digit(char int)
Returns theClass Character, int getType(char)int
value that the specified Unicodenumericcharactervaluerepresents.ofFor example the characteras'\u216C'
(the roman numeral fifty) will return an int with anonnegativevalueintegerof 50.The letters A-Z in their uppercase (
. This is independent of the Unicode specification which does not assign numeric values to these'\u0041'
through'\u005A'
) lowercase ('\u0061'
through'\u007A'
) and full width variant ('\uFF21'
through'\uFF3A'
and'\uFF41'
through'\uFF5A'
) forms have numeric values from 10 through 35char
values.If the character does not have a numeric value then -1 is returned. If the character has a numeric value that cannot be represented as a nonnegative integer (for example a fractional value) then -2 is returned. @param ch the character to be converted. @return the numeric value of the character as a nonnegative
int
value; -2 if the character has a numeric value that is not a nonnegative integer; -1 if the character has no numeric value. @see java.lang.Character#forDigit(int int) @see java.lang.Character#isDigit(char) @sinceJDK11.1
Returns a value indicating a character's general category. @param ch the character to be tested. @return a value of typeClass Character, int hashCode()int
representing the character's general category. @see java.lang.Character#COMBINING_SPACING_MARK @see java.lang.Character#CONNECTOR_PUNCTUATION @see java.lang.Character#CONTROL @see java.lang.Character#CURRENCY_SYMBOL @see java.lang.Character#DASH_PUNCTUATION @see java.lang.Character#DECIMAL_DIGIT_NUMBER @see java.lang.Character#ENCLOSING_MARK @see java.lang.Character#END_PUNCTUATION @see java.lang.Character#FINAL_QUOTE_PUNCTUATION @see java.lang.Character#FORMAT @see java.lang.Character#INITIAL_QUOTE_PUNCTUATION @see java.lang.Character#LETTER_NUMBER @see java.lang.Character#LINE_SEPARATOR @see java.lang.Character#LOWERCASE_LETTER @see java.lang.Character#MATH_SYMBOL @see java.lang.Character#MODIFIER_LETTER @see java.lang.Character#MODIFIER_SYMBOL @see java.lang.Character#NON_SPACING_MARK @see java.lang.Character#OTHER_LETTER @see java.lang.Character#OTHER_NUMBER @see java.lang.Character#OTHER_PUNCTUATION @see java.lang.Character#OTHER_SYMBOL @see java.lang.Character#PARAGRAPH_SEPARATOR @see java.lang.Character#PRIVATE_USE @see java.lang.Character#SPACE_SEPARATOR @see java.lang.Character#START_PUNCTUATION @see java.lang.Character#SURROGATE @see java.lang.Character#TITLECASE_LETTER @see java.lang.Character#UNASSIGNED @see java.lang.Character#UPPERCASE_LETTER @sinceJDK11.1
Returns a hash code for this Character
. @return a hash code value for this object.
Class Character, boolean isDefined(char)Determines if a characterClass Character, boolean isDigit(char)has ais definedmeaningin Unicode.A character is defined if at least one of the following is true:
@param ch the character to be tested @return
- It has an entry in the
Unicode attributeUnicodeDatatablefile.ItsItvalue ishas a value inthea range'\u3040' <= ch <= '\u9FA5'. Its value isdefinedinby therangeUnicodeData'\uF900' <= ch <= '\uFA2D'file.true
if the character has a defined meaning in Unicode;false
otherwise. @see java.lang.Character#isDigit(char) @see java.lang.Character#isLetter(char) @see java.lang.Character#isLetterOrDigit(char) @see java.lang.Character#isLowerCase(char) @see java.lang.Character#isTitleCase(char) @see java.lang.Character#isUpperCase(char) @sinceJDK11.0.2
Determines if the specified character is a digit.Class Character, boolean isISOControl(char)A character is
considered to bea digit ifit is not in the rangeits general category type provided by
'\u2000' <=Character.getType(ch<= '\u2FFF')and its Unicode name contains the wordis"DECIMAL_DIGIT_NUMBER
". For a more complete specification that encompasses all Unicode characters that are defined as digits see Gosling Joy and Steele The Java Language Specification.
These are theSome Unicode character rangesof Unicode charactersthatare consideredcontain digits:
0x0030'\u0030'
through0x0039'\u0039'
ISO-LATIN-1 digits ('0'
through'9'
)0x0660'\u0660'
through0x0669'\u0669'
Arabic-Indic digits0x06F0'\u06F0'
through0x06F9'\u06F9'
Extended Arabic-Indic digits0x0966'\u0966'
through0x096F'\u096F'
Devanagari digits0x09E6 through 0x09EF Bengali digits 0x0A66 through 0x0A6F Gurmukhi digits 0x0AE6 through 0x0AEF Gujarati digits 0x0B66 through 0x0B6F Oriya digits 0x0BE7 through 0x0BEF Tamil digits 0x0C66 through 0x0C6F Telugu digits 0x0CE6 through 0x0CEF Kannada digits 0x0D66 through 0x0D6F Malayalam digits0x0E50'\uFF10'
through0x0E59'\uFF19'
ThaiFullwidth digits0x0ED0 through 0x0ED9LaodigitsMany0x0F20otherthroughcharacter0x0F29rangesTibetancontain digits0xFF10 through 0xFF19 Fullwidthdigitsas well. @param ch the character to be tested. @returntrue
if the character is a digit;false
otherwise. @see java.lang.Character#digit(char int) @see java.lang.Character#forDigit(int int) @see java.lang.Character#getType(char)
Determines if the specified character is an ISO control character. A character is considered to be an ISO control character if its code is in the rangeClass Character, boolean isIdentifierIgnorable(char)'\u0000'
through'\u001F'
or in the range'\u007F'
through'\u009F'
. @param ch the character to be tested. @returntrue
if the character is an ISO control character;false
otherwise. @see java.lang.Character#isSpaceChar(char) @see java.lang.Character#isWhitespace(char) @sinceJDK11.1
Determines if the specified character should be regarded as an ignorable character in a Java identifier or a Unicode identifier.Class Character, boolean isJavaIdentifierPart(char)The following Unicode characters are ignorable in a Java identifier or a Unicode identifier:
0x0000 through 0x0008
- ISO control characters that
0x000E through 0x001Bare not whitespace
and'\u0000'
through0x007F'\u0008'
'\u000E'
through0x009F 0x200C'\u001B'
'\u007F'
through0x200F'\u009F'
joincontrols 0x200Aall throughcharacters0x200Ethatbidirectionalhavecontrols 0x206AthethroughFORMAT
0x206Fgeneralformatcategorycontrols 0xFEFF zero-width no-break spacevalue @param ch the character to be tested. @returntrue
if the character is an ignorable control character that may be part of a Java or Unicode identifier;false
otherwise. @see java.lang.Character#isJavaIdentifierPart(char) @see java.lang.Character#isUnicodeIdentifierPart(char) @sinceJDK11.1
Determines if the specified character may be part of a Java identifier as other than the first character.Class Character, boolean isJavaIdentifierStart(char)A character may be part of a Java identifier if
and only if it is oneany of the following are true:@param ch the character to be tested. @return
- it is a letter
- it is a currency symbol (such as
"'$
)"'- it is a connecting punctuation character (such as
"'_
)"'.- it is a digit
- it is a numeric letter (such as a Roman numeral character)
- it is a combining mark
- it is a non-spacing mark
anisIdentifierIgnorable
returnstrue
ignorable controlfor the charactertrue
if the character may be part of aUnicodeJava identifier;false
otherwise. @see java.lang.Character#isIdentifierIgnorable(char) @see java.lang.Character#isJavaIdentifierStart(char) @see java.lang.Character#isLetterOrDigit(char) @see java.lang.Character#isUnicodeIdentifierPart(char) @sinceJDK11.1
Determines if the specified character is permissible as the first character in a Java identifier.Class Character, boolean isJavaLetter(char)A character may start a Java identifier if and only if
it isone of the following conditions is true:@param ch the character to be tested. @return
aisLetter(ch) returnstrue
letter- getType(ch) returns
LETTER_NUMBER
- ch is a currency symbol (such as "$")
- ch is a connecting punctuation character (such as "_").
true
if the character may start a Java identifier;false
otherwise. @see java.lang.Character#isJavaIdentifierPart(char) @see java.lang.Character#isLetter(char) @see java.lang.Character#isUnicodeIdentifierStart(char) @sinceJDK11.1
Determines if the specified character isClass Character, boolean isJavaLetterOrDigit(char)a "Java" letter that is the character ispermissible as the first character inan identifier in thea Javalanguageidentifier.A character
is considered tomaybestart a Javaletteridentifier if and only ifitone of the following isatrue:letter@param ch the character to be tested. @return
the- isLetter(ch)
ASCIIreturnsdollartrue
signcharactergetType(ch) returns
'$'LETTER_NUMBERorthech is a currency symbol (such as "$")- ch is
underscorea connecting punctuation character'(such as "_'").true
if the characterismay start a Javaletteridentifier;false
otherwise. @see java.lang.Character#isJavaLetterOrDigit(char) @see java.lang.Character#isJavaIdentifierStart(char) @see java.lang.Character#isJavaLetterOrDigitisJavaIdentifierPart(char) @see java.lang.Character#isLetter(char) @see java.lang.Character#isLetterOrDigit(char) @see java.lang.Character#isUnicodeIdentifierStart(char) @sinceJDK1.01.202 @deprecated Replaced by isJavaIdentifierStart(char).
Determines if the specified characterClass Character, boolean isLetter(char)is a "Java" letter or digit that is themaycharacter isbepermissible aspart of anon-initial characterJavain an identifier inidentifier as other than theJavafirstlanguagecharacter.A character
ismayconsidered to bebe part of a Javaletter or digitidentifier if and only if any of the following are true:it is a letter
a digit the ASCII dollar signit is a currency symbol character(such as'$'
)ortheit is a connectingunderscorepunctuation character (such as'_'
)it is a digit it is a numeric letter (such as a Roman numeral character) it is a combining mark it is a non-spacing mark . @param ch the character to be tested. @return isIdentifierIgnorable
returnstrue
for the charactertrue
if the characteris a Java letter ormay be part of adigitJava identifier;false
otherwise. @see java.lang.Character#isJavaIdentifierPartisJavaLetter(char) @see java.lang.Character#isJavaLetterisJavaIdentifierStart(char) @see java.lang.Character#isJavaIdentifierPart(char) @see java.lang.Character#isLetter(char) @see java.lang.Character#isLetterOrDigit(char) @see java.lang.Character#isUnicodeIdentifierPart(char) @since JDK1see java.0lang.Character#isIdentifierIgnorable(char) @since 1.202 @deprecated Replaced by isJavaIdentifierPart(char).
Determines if the specified character is a letter.Class Character, boolean isLetterOrDigit(char)For a more complete specification that encompasses all Unicode characters see Gosling Joy and Steele The Java Language Specification.A character is considered to be a letter if
and only if it is specifieditsto be a lettergeneral category type provided bythe Unicode 2Character.
0 standardgetType(category "Lu" "Ll" "Lt" "Lm" or "Lo" in the Unicode specification data filech). Note thatmost ideographic characters areis any of theconsideredfollowing:to beNot all letters have case
lettersUPPERCASE_LETTER
(category"Lo")LOWERCASE_LETTER
forthisTITLECASE_LETTER
purpose.MODIFIER_LETTER
NotealsoOTHER_LETTER
that not: many.UnicodeMany characters are letters but are neither uppercase nor lowercase nor titlecase. @param ch the character to be tested. @returntrue
if the character is a letter;false
otherwise. @see java.lang.Character#isDigit(char) @see java.lang.Character#isJavaIdentifierStart(char) @see java.lang.Character#isJavaLetter(char) @see java.lang.Character#isJavaLetterOrDigit(char) @see java.lang.Character#isLetterOrDigit(char) @see java.lang.Character#isLowerCase(char) @see java.lang.Character#isTitleCase(char) @see java.lang.Character#isUnicodeIdentifierStart(char) @see java.lang.Character#isUpperCase(char)
Determines if the specified character is a letter or digit.Class Character, boolean isLowerCase(char)For a more complete specification that encompasses all Unicode characters see Gosling Joy and Steele The Java Language Specification.A character is considered to be a letter
if and only if it is specified to be a letteroradigitby the Unicode 2.0 standard (category "Lu" "Ll" "Lt" "Lm" "Lo" or "Nd" in the Unicode specification data file). In other words isLetterOrDigit is true of a character if and onlyif eitherCharacter.isLetter
oris true of the(charcharacterch)Character.isDigit(char
returnsisch)true
offor the character. @param ch the character to be tested. @returntrue
if the character is a letter or digit;false
otherwise. @see java.lang.Character#isDigit(char) @see java.lang.Character#isJavaIdentifierPart(char) @see java.lang.Character#isJavaLetter(char) @see java.lang.Character#isJavaLetterOrDigit(char) @see java.lang.Character#isLetter(char) @see java.lang.Character#isUnicodeIdentifierPart(char) @sinceJDK11.0.2
Determines if the specified character is a lowercase character.Class Character, boolean isSpace(char)A character is lowercase if
it is notitsin the rangegeneral category type'\u2000'providedthroughby
'\u2FFF'Character.getType(ch)the Unicode attribute table does not specify a mapping to lowercase for the character and at least one of the followingistrue: The attribute table specifies a mapping to uppercase for the character. The name for the character contains the words "
SMALLLOWERCASE_LETTER". The name for the character contains the words "SMALL LIGATURE".
A character is considered to be lowercase if and only if itTheis specified to befollowing are examples of lowercaseby the Unicode 2.0 standard (category "Ll" in the Unicode specification data file). Of the ISO-LATIN-1characters(character codes 0x0000 through 0x00FF) the following are lowercase:a b c d e f g h i j k l m n o p q r s t u v w x y z '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6' '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE' '\u00EF' '\u00F0' '\u00F1' '\u00F2' '\u00F3' '\u00F4' '\u00F5' '\u00F6' '\u00F8' '\u00F9' '\u00FA' '\u00FB' '\u00FC' '\u00FD' '\u00FE' '\u00FF'Many other Unicode characters are lowercase too.
@param ch the character to be tested. @return
true
if the character is lowercase;false
otherwise. @see java.lang.Character#isLowerCase(char) @see java.lang.Character#isTitleCase(char) @see java.lang.Character#toLowerCase(char) @see java.lang.Character#getType(char)
Determines if the specified character is ISO-LATIN-1 white space. This method returnsClass Character, boolean isSpaceChar(char)true
for the following five characters only:@param ch the character to be tested. @return
'\t'
'\u0009'
HORIZONTAL TABULATION
'\n'
'\u000A'
NEW LINE
'\f'
'\u000C'
FORM FEED
'\r'
'\u000D'
CARRIAGE RETURN
'
''\u0020'
SPACE
true
if the character is ISO-LATIN-1 white space;false
otherwise. @see java.lang.Character#isSpaceChar(char) @see java.lang.Character#isWhitespace(char) @deprecated Replaced by isWhitespace(char).
Determines if the specified character is a Unicode space character. A character is considered to be a space character if and only if it is specified to be a space character by the UnicodeClass Character, boolean isTitleCase(char)2standard.0standardThis(categorymethod returns true if the character's"Zs"general"Zlcategory typeoris"Zp"anyinof theUnicodefollowing:specification data@param ch the character to be tested. @return
file).SPACE_SEPARATOR
LINE_SEPARATOR
PARAGRAPH_SEPARATOR
true
if the character is a space character;false
otherwise. @see java.lang.Character#isWhitespace(char) @sinceJDK11.1
Determines if the specified character is a titlecase character.Class Character, boolean isUnicodeIdentifierPart(char)A character is
considered to bea titlecaseif and onlycharacter ifit isitsspecified to be titlecasegeneral category type provided bythe Unicode 2Character.
0 standardgetType(category "Lt" in the Unicode specificationch)dataisfile)TITLECASE_LETTER
.
The printed representations of four UnicodeSome characters look like pairs of Latin letters. For example there is an uppercase letter that looks like "LJ" and has a corresponding lowercase letter that looks like "lj". A third form which looks like "Lj" is the appropriate form to use when rendering a word in lowercase with initial capitals as for a book title.These are some of the Unicode characters for which this method returns
true
:
LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
LATIN CAPITAL LETTER L WITH SMALL LETTER J
LATIN CAPITAL LETTER N WITH SMALL LETTER J
LATIN CAPITAL LETTER D WITH SMALL LETTER Z
Many other Unicode characters are titlecase too.
@param ch the character to be tested. @return
true
if the character is titlecase;false
otherwise. @see java.lang.Character#isLowerCase(char) @see java.lang.Character#isUpperCase(char) @see java.lang.Character#toTitleCase(char) @see java.lang.Character#getType(char) @sinceJDK11.0.2
Determines if the specified character may be part of a Unicode identifier as other than the first character.Class Character, boolean isUnicodeIdentifierStart(char)A character may be part of a Unicode identifier if and only if
it isone of the following statements is true:@param ch the character to be tested. @return
- it is a letter
- it is a connecting punctuation character (such as
"'_
)"'.- it is a digit
- it is a numeric letter (such as a Roman numeral character)
- it is a combining mark
- it is a non-spacing mark
anisIdentifierIgnorable
returnstrue
ignorable controlfor this character.true
if the character may be part of a Unicode identifier;false
otherwise. @see java.lang.Character#isIdentifierIgnorable(char) @see java.lang.Character#isJavaIdentifierPart(char) @see java.lang.Character#isLetterOrDigit(char) @see java.lang.Character#isUnicodeIdentifierStart(char) @sinceJDK11.1
Determines if the specified character is permissible as the first character in a Unicode identifier.Class Character, boolean isUpperCase(char)A character may start a Unicode identifier if and only if
itone of the following conditions isatrue:
- isLetter(ch) returns
true
- getType(ch)
letterreturnsLETTER_NUMBER
. @param ch the character to be tested. @returntrue
if the character may start a Unicode identifier;false
otherwise. @see java.lang.Character#isJavaIdentifierStart(char) @see java.lang.Character#isLetter(char) @see java.lang.Character#isUnicodeIdentifierPart(char) @sinceJDK11.1
Determines if the specified character is an uppercase character.Class Character, boolean isWhitespace(char)A character is uppercase if
it is notitsin the rangegeneral category type'\u2000'providedthroughby
'\u2FFF'Character.getType(ch)the Unicode attribute table does not specify a mapping to uppercase for the character and at least one of the followingistrue: The attribute table specifies a mapping to lowercase for the character. The name for the character contains the words "
CAPITALUPPERCASE_LETTER". The name for the character contains the words "CAPITAL LIGATURE".
Of the ISO-LATIN-1 characters (character codes 0x0000 through 0x00FF) theThe following are examples of uppercase characters:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7' '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF' '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8' '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'Many other Unicode characters are uppercase too.
@param ch the character to be tested. @return
true
if the character is uppercase;false
otherwise. @see java.lang.Character#isLowerCase(char) @see java.lang.Character#isTitleCase(char) @see java.lang.Character#toUpperCase(char) @see java.lang.Character#getType(char) @since 1.0
Determines if the specified character is white space according to Java. A character isClass Character, char toLowerCase(char)considered to bea Java whitespace character if and only if it satisfies one of the following criteria:@param ch the character to be tested. @return
- It is a Unicode space
separatorcharacter (categorySPACE_SEPARATOR
"Zs"LINE_SEPARATOR
orPARAGRAPH_SEPARATOR
) but is not also anonon-breakbreaking space ('\u00A0'
or'\
uFEFF). It is a Unicode line separator (category "Zl"). It isu2007'a Unicode paragraph separator (category "Zp"'\u202F'
).- It is
'\u0009'
HORIZONTAL TABULATION.- It is
'\u000A'
LINE FEED.- It is
'\u000B'
VERTICAL TABULATION.- It is
'\u000C'
FORM FEED.- It is
'\u000D'
CARRIAGE RETURN.- It is
'\u001C'
FILE SEPARATOR.- It is
'\u001D'
GROUP SEPARATOR.- It is
'\u001E'
RECORD SEPARATOR.- It is
'\u001F'
UNIT SEPARATOR.true
if the character is a Java whitespace character;false
otherwise. @see java.lang.Character#isSpaceChar(char) @sinceJDK11.1
Class Character, String toString()TheConvertsgiven character is mapped to its lowercase equivalent; ifthe characterhas no lowercase equivalent the character itself is returned. A character hasargumentato lowercaseequivalent if and only if ausinglowercasecase mappingis specified for the characterinformationinfrom theUnicode attributeUnicodeDatatablefile.Note that
some Unicode characters in the range '\u2000' to
'\u2FFF'Character.isLowerCase(Character.toLowerCase(ch))have lowercase mappings; this methoddoesmap such characters tonottheir lowercasealways returnequivalentstrue
even though the methodfor some ranges ofisUpperCasecharactersdoes not returnparticularly those thattruearefor such characterssymbols or ideographs. @param ch the character to be converted. @return the lowercase equivalent of the character if any; otherwise the character itself. @see java.lang.Character#isLowerCase(char) @see java.lang.Character#isUpperCase(char) @see java.lang.Character#toTitleCase(char) @see java.lang.Character#toUpperCase(char)
Returns aClass Character, char toTitleCase(char)String
object representing thischaracter's value. Converts thisCharacter
object to a'sstringvalue. The result is a stringwhoseof lengthis1. Thestring'swhose sole component is the primitivechar
value represented by thisCharacter
object. @return a string representation of this object.
Converts the character argument to titlecaseClass Character, char toUpperCase(char). Acharacter has a titlecase equivalent if andusing case mapping information from the UnicodeDataonlyfile.ifIf atitlecasecharactermapping is specified for the character in the Unicode attributehas no explicit titlecase mapping and is not itself atable.titlecaseNote that some Unicode characters in the rangechar according to UnicodeData then the uppercase mapping is'\u2000'returnedthroughas'\u2FFF'anhaveequivalent titlecasemappings; thismapping.method doesIf themapchar
such characters to theirargument is already a titlecaseequivalents even though the method
isTitleCasechardoes notthereturnsame
truecharfor suchvalue willcharactersbe returned.
There are only four Unicode characters that are truly titlecase formsNote thatare distinct from uppercase formsCharacter.
As a rule if a character has no true titlecase equivalent but does have an uppercase mapping then the Unicode 2isTitleCase(Character.0 attribute table specifies atoTitleCase(ch))titlecase mapping that isdoes not always returnthetrue
same as the uppercase mappingfor some ranges of characters. @param ch the character to be converted. @return the titlecase equivalent of the character if any; otherwise the character itself. @see java.lang.Character#isTitleCase(char) @see java.lang.Character#toLowerCase(char) @see java.lang.Character#toUpperCase(char) @sinceJDK11.0.2
Converts the character argument to uppercaseClass Character, byte COMBINING_SPACING_MARK. A character has an uppercase equivalent if and onlyif anusinguppercasecase mappingis specified for the characterinformationinfrom theUnicode attributeUnicodeDatatablefile.Note that
some Unicode characters in the range '\u2000' to
'\u2000FFF'Character.isUpperCase(Character.toUpperCase(ch))have uppercase mappings; this methoddoesmap such characters tonottheir titlecasealways returnequivalentstrue
even though the methodfor some ranges ofisLowerCasecharactersdoes not returnparticularly those thattruearefor such characterssymbols or ideographs. @param ch the character to be converted. @return the uppercase equivalent of the character if any; otherwise the character itself. @see java.lang.Character#isLowerCase(char) @see java.lang.Character#isUpperCase(char) @see java.lang.Character#toLowerCase(char) @see java.lang.Character#toTitleCase(char)
Class Character, byte CONNECTOR_PUNCTUATIONPublicGeneraldata forcategoryenumerated"Mc"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte CONTROLPublicGeneraldata forcategoryenumerated"Pc"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte CURRENCY_SYMBOLPublicGeneraldata forcategoryenumerated"Cc"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte DASH_PUNCTUATIONPublicGeneraldata forcategoryenumerated"Sc"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte DECIMAL_DIGIT_NUMBERPublicGeneraldata forcategoryenumerated"Pd"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte ENCLOSING_MARKPublicGeneraldata forcategoryenumerated"Nd"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte END_PUNCTUATIONPublicGeneraldata forcategoryenumerated"Me"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte FORMATPublicGeneraldata forcategoryenumerated"Pe"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte LETTER_NUMBERPublicGeneraldata forcategoryenumerated"Cf"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte LINE_SEPARATORPublicGeneraldata forcategoryenumerated"Nl"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte LOWERCASE_LETTERPublicGeneraldata forcategoryenumerated"Zl"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte MATH_SYMBOLPublicGeneraldata forcategoryenumerated"Ll"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, int MAX_RADIXPublicGeneraldata forcategoryenumerated"Sm"Unicode general category typesin the Unicode specification. @sinceJDK11.1
The maximum radix available for conversion to and fromClass Character, char MAX_VALUEStringsstrings. The constant value of this field is the largest value permitted for the radix argument in radix-conversion methods such as thedigit
method theforDigit
method and thetoString
method of classInteger
. @see java.lang.Character#digit(char int) @see java.lang.Character#forDigit(int int) @see java.lang.Integer#toString(int int) @see java.lang.Integer#valueOf(java.lang.String)
The constant value of this field is the largest value of typeClass Character, int MIN_RADIXchar
'\uFFFF'
. @sinceJDK11.0.2
The minimum radix available for conversion to and fromClass Character, char MIN_VALUEStringsstrings. The constant value of this field is the smallest value permitted for the radix argument in radix-conversion methods such as thedigit
method theforDigit
method and thetoString
method of classInteger
. @see java.lang.Character#digit(char int) @see java.lang.Character#forDigit(int int) @see java.lang.Integer#toString(int int) @see java.lang.Integer#valueOf(java.lang.String)
The constant value of this field is the smallest value of typeClass Character, byte MODIFIER_LETTERchar
'\u0000'
. @sinceJDK11.0.2
Class Character, byte MODIFIER_SYMBOLPublicGeneraldata forcategoryenumerated"Lm"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte NON_SPACING_MARKPublicGeneraldata forcategoryenumerated"Sk"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte OTHER_LETTERPublicGeneraldata forcategoryenumerated"Mn"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte OTHER_NUMBERPublicGeneraldata forcategoryenumerated"Lo"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte OTHER_PUNCTUATIONPublicGeneraldata forcategoryenumerated"No"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte OTHER_SYMBOLPublicGeneraldata forcategoryenumerated"Po"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte PARAGRAPH_SEPARATORPublicGeneraldata forcategoryenumerated"So"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte PRIVATE_USEPublicGeneraldata forcategoryenumerated"Zp"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte SPACE_SEPARATORPublicGeneraldata forcategoryenumerated"Co"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte START_PUNCTUATIONPublicGeneraldata forcategoryenumerated"Zs"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte SURROGATEPublicGeneraldata forcategoryenumerated"Ps"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, byte TITLECASE_LETTERPublicGeneraldata forcategoryenumerated"Cs"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Class Character, Class TYPEPublicGeneraldata forcategoryenumerated"Lt"Unicode general category typesin the Unicode specification. @sinceJDK11.1
TheClass Character, byte UNASSIGNEDClass
objectinstance representing the primitive typechar
. @sinceJDK11.1
Class Character, byte UPPERCASE_LETTERPublicGeneraldata forcategoryenumerated"Cn"Unicode general category typesin the Unicode specification. @sinceJDK11.1
PublicGeneraldata forcategoryenumerated"Lu"Unicode general category typesin the Unicode specification. @sinceJDK11.1
Instances of the classClass Class, Class forName(String, boolean, ClassLoader)Class
represent classes and interfaces in a running Java application. Every array also belongs to a class that is reflected as aClass
object that is shared by all arrays with the same element type and number of dimensions. The primitive Java types (boolean
byte
char
short
int
long
float
anddouble
) and the keywordvoid
are also represented asClass
objects.
Class
has no public constructor. InsteadClass
objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to thedefineClass
method in the class loader.The following example uses a
Class
object to print the class name of an object:
@author unascribed @version 1.void printClassName(Object obj) { System.out.println("The class of " + obj + " is " + obj.getClass().getName()); }107 02135 05/0225/0001 @see java.lang.ClassLoader#defineClass(byte[] int int) @since JDK1.0
Returns theClass Class, Method getDeclaredMethod(String, Class[])Class
object associated with the class or interface with the given string name using the given class loader. Given the fully qualified name for a class or interface (in the same format returned bygetName
) this method attempts to locate load and link the class or interface. The specified class loader is used to load the class or interface. If the parameterloader
is null the class is loaded through the bootstrap class loader. The class is initialized only if theinitialize
parameter istrue
and if it has not been initialized earlier.If
name
denotes a primitive type or void an attempt will be made to locate a user-defined class in the unnamed package whose name isname
. Therefore this method cannot be used to obtain any of theClass
objects representing primitive types or void.If
name
denotes an array class the component type of the array class is loaded but not initialized.For example in an instance method the expression:
is equivalent to:Class.forName("Foo")Note that this method throws errors related to loading linking or initializing as specified in Sections 12.2 12.3 and 12.4 of The Java Language Specification. Note that this method does not check whether the requested class is accessible to its caller.Class.forName("Foo" true this.getClass().getClassLoader())If the
loader
isnull
and a security manager is present and the caller's class loader is not null then this method calls the security manager'scheckPermission
method with aRuntimePermission("getClassLoader")
permission to ensure it's ok to access the bootstrap class loader. @param name fully qualified name of the desired class @param initialize whether the class must be initialized @param loader class loader from which the class must be loaded @return class object representing the desired class @exception LinkageError if the linkage fails @exception ExceptionInInitializerError if the initialization provoked by this method fails @exception ClassNotFoundException if the class cannot be located by the specified class loader @see java.lang.Class#forName(String) @see java.lang.ClassLoader @since 1.2
Returns aClass Class, Field[] getFields()Method
object that reflects the specified declared method of the class or interface represented by thisClass
object. Thename
parameter is aString
that specifies the simple name of the desired method and theparameterTypes
parameter is an array ofClass
objects that identify the method's formal parameter types in declared order. If more than one method with the same parameter types is declared in a class and one of these methods has a return type that is more specific than any of the others that method is returned; otherwise one of the methods is chosen arbitrarily. If the name is "<init>"or "<clinit>" aNoSuchMethodException
is raised.If there is a security manager this method first calls the security manager's
checkMemberAccess
method withthis
andMember.DECLARED
as its arguments. If the class is in a package then this method also calls the security manager'scheckPackageAccess
method with the package name as its argument. Either of these calls could result in a SecurityException. @param name the name of the method @param parameterTypes the parameter array @return theMethod
object for the method of this class matching the specified name and parameters @exception NoSuchMethodException if a matching method is not found. @exception SecurityException if access to the information is denied. @see java.lang.reflect.Method @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1
Returns an array containingClass Class, Method getMethod(String, Class[])Field
objects reflecting all the accessible public fields of the class or interface represented by thisClass
object. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface has no accessible public fields or if it represents an array class a primitive type or void.Specifically if this
Class
object represents a class this method returns the public fields of this class and of all its superclasses. If thisClass
object represents an interface this method returns the fields of this interface and of all its superinterfaces.If there is a security manager this method first calls the security manager's
checkMemberAccess
method withthis
andMember.PUBLIC
as its arguments. If the class is in a package then this method also calls the security manager'scheckPackageAccess
method with the package name as its argument. Either of these calls could result in a SecurityException.The implicit length field for array
classsclass is not reflected by this method. User code should use the methods of classArray
to manipulate arrays.See The Java Language Specification sections 8.2 and 8.3. @return the array of
Field
objects representing the public fields @exception SecurityException if access to the information is denied. @see java.lang.reflect.Field @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1
Returns aClass Class, Method[] getMethods()Method
object that reflects the specified public member method of the class or interface represented by thisClass
object. Thename
parameter is aString
specifying the simple name the desired method. TheparameterTypes
parameter is an array ofClass
objects that identify the method's formal parameter types in declared order. IfparameterTypes
isnull
it is treated as if it were an empty array.If there is a security manager this method first calls the security manager's
checkMemberAccess
method withthis
andMember.PUBLIC
as its arguments. If the class is in a package then this method also calls the security manager'scheckPackageAccess
method with the package name as its argument. Either of these calls could result in a SecurityException.If the
name
is "<init>"or "<clinit>" aNoSuchMethodException
is raised. Otherwise the method to be reflected is determined by the algorithm that follows. Let C be the class represented by this object:To find a matching method in a class C: If C declares exactly one public method with the specified name and exactly the same formal parameter types that is the method reflected. If more than one such method is found in C and one of these methods has a return type that is more specific than any of the others that method is reflected; otherwise one of the methods is chosen arbitrarily.
- C is searched for any matching methods. If no matching method is found the algorithm of step 1 is invoked recursively on the superclass of C.
- If no method was found in step 1 above the superinterfaces of C are searched for a matching method. If any such method is found it is reflected.
See The Java Language Specification sections 8.2 and 8.4. @param name the name of the method @param parameterTypes the list of parameters @return the
Method
object that matches the specifiedname
andparameterTypes
@exception NoSuchMethodException if a matching method is not found or if then name is "<init>"or "<clinit>". @exception SecurityException if access to the information is denied. @see java.lang.reflect.Method @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1
Returns an array containingClass Class, int getModifiers()Method
objects reflecting all the public member methods of the class or interface represented by thisClass
object including those declared by the class or interface and and those inherited from superclasses and superinterfaces. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if thisClass
object represents a class or interface that has no public member methods or if thisClass
object represents an array class primitive type or void.If there is a security manager this method first calls the security manager's
checkMemberAccess
method withthis
andMember.PUBLIC
as its arguments. If the class is in a package then this method also calls the security manager'scheckPackageAccess
method with the package name as its argument. Either of these calls could result in a SecurityException.The class initialization method
<clinit>
is not included in the returned array. If the class declares multiple public member methods with the same parameter types they are all included in the returned array.See The Java Language Specification sections 8.2 and 8.4. @return the array of
Method
objects representing the public methods of this class @exception SecurityException if access to the information is denied. @see java.lang.reflect.Method @see SecurityManager#checkMemberAccess(Class int) @see SecurityManager#checkPackageAccess(String) @since JDK1.1
Returns the Java language modifiers for this class or interface encoded in an integer. The modifiers consist of the Java Virtual Machine's constants forClass Class, String getName()public
protected
private
final
static
abstract
andinterface
; they should be decoded using the methods of classModifier
.If the underlying class is an array class then its
public
private
andprotected
modifiers are the same as those of its component type. If thisClass
represents a primitive type or void itspublic
modifier is alwaystrue
and itsprotected
andprivate
modifersmodifiers are alwaysfalse
. If this object represents an array class a primitive type or void then itsfinal
modifier is alwaystrue
and its interfacemodifermodifier is alwaysfalse
. The values of its other modifiers are not determined by this specification.The modifier encodings are defined in The Java Virtual Machine Specification table 4.1. @return the
int
representing the modifiers for this class @see java.lang.reflect.Modifier @since JDK1.1
Returns theIf this class object represents a class of arrays then the internal form of the name consists of the name of the element typefully-qualifiedname of the entity (class interface array class primitive type or void) represented by thisClass
object as aString
.If this
Classclass object represents a reference type that is not an array type then the binary name of the class is returned as specified by the Java Language Specification Second Edition. If this class object represents a primitive type or void then the name returned is the name determined by the following table. The encoding of element type names is as follows:D double F float I int J long Lclassname; class or interface S short Z boolean V voidB byte C char
returns "(new Object[3]).getClass().getName()
[Ljava.lang.Object;
" and: returns "(new int[3][4][5][6][7][8][9]).getClass().getName()
[[[[[[[I
". The Returns theClass Class, InputStream getResourceAsStream(String)ProtectionDomain
of this class. If there is a security manager installed this method first calls the security manager'scheckPermission
method with aRuntimePermission("getProtectionDomain")
permission to ensure it's ok to get theProtectionDomain
. @return the ProtectionDomain of this class @throws SecurityException if a security manager exists and itscheckPermission
method doesn't allowgetinggetting the ProtectionDomain. @see java.security.ProtectionDomain @see SecurityManager#checkPermission @see java.lang.RuntimePermission @since 1.2
Finds a resource with a given name. This method returns null if no resource with this name is found. The rules for searching resources associated with a given class are implemented by the defining class loader of the class.Class Class, Object newInstance()This method delegates the call to its class loader after making these changes to the resource name: if the resource name starts with "/" it is unchanged; otherwise the package name is prepended to the resource name after converting "." to "/". If this object was loaded by the bootstrap loader the call is delegated to
ClassLoader.getSystemResourceAsStream
. @param name name of the desired resource @return ajava.io.InputStream
object. @throws NullPointerException ifname
isnull
. @see java.lang.ClassLoader @since JDK1.1
Creates a new instance of the class represented by this Class object. The class isinstantiatiedinstantiated as if by anew
expression with an empty argument list. The class is initialized if it has not already been initialized.If there is a security manager this method first calls the security manager's
checkMemberAccess
method withthis
andMember.PUBLIC
as its arguments. If the class is in a package then this method also calls the security manager'scheckPackageAccess
method with the package name as its argument. Either of these calls could result in a SecurityException. @return a newly allocated instance of the class represented by this object. @exception IllegalAccessException if the class orinitializerits nullary constructor is not accessible. @exception InstantiationException if thisClass
represents an abstract class an interface an array class a primitive type or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason. @exception ExceptionInInitializerError if the initialization provoked by this method fails. @exception SecurityException if there is no permission to create a new instance.
Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. For example the following code generates aClassCastException
:@author unascribed @version 1.Object x = new Integer(0); System.out.println((String)x);17 0218 12/0203/0001 @since JDK1.0
Thrown when a circularity has been detected while initializing a class. @author unascribed @version 1.12 0213 12/0203/0001 @since JDK1.0
Thrown when the Java Virtual Machine attempts to read a class file and determines that the file is malformed or otherwise cannot be interpreted as a class file. @author unascribed @version 1.17 0218 12/0203/0001 @since JDK1.0
Class ClassLoader, constructor ClassLoader(ClassLoader)The class ClassLoader is an abstract class.A class loader is an object that is responsible for loading classes. The classClassLoader
is an abstract class. Given the name of a classita class loader should attempt to locate or generate data that constitutes a definition for the class. A typical strategy is to transform the name into a file name and then read a "class file" of that name from a file system.Every
Class
object contains a reference to theClassLoader
that defined it.Class objects for array classes are not created by class loaders but are created automatically as required by the Java runtime. The class loader for an array class as returned by Class#getClassLoader() is the same as the class loader for its element type; if the element type is a primitive type then the array class has no class loader.
Applications implement subclasses of
ClassLoader
in order to extend the manner in which the Java virtual machine dynamically loads classes.Class loaders may typically be used by security managers to indicate security domains.
The
ClassLoader
class uses a delegation model to search for classes and resources. Each instance ofClassLoader
has an associated parent class loader. When called upon to find a class or resource aClassLoader
instance will delegate the search for the class or resource to its parent class loader before attempting to find the class or resource itself. The virtual machine's built-in class loader called the bootstrap class loader does not itself have a parent but may serve as the parent of aClassLoader
instance.Normally the Java virtual machine loads classes from the local file system in a platform-dependent manner. For example on UNIX systems the virtual machine loads classes from the directory defined by the
CLASSPATH
environment variable.However some classes may not originate from a file; they may originate from other sources such as the network or they could be constructed by an application. The method
defineClass
converts an array of bytes into an instance of classClass
. Instances of this newly defined class can be created using thenewInstance
method in classClass
.The methods and constructors of objects created by a class loader may reference other classes. To determine the class(es) referred to the Java virtual machine calls the
loadClass
method of the class loader that originally created the class.For example an application could create a network class loader to download class files from a server. Sample code might look like:
ClassLoader loader = new NetworkClassLoader(host port); Object main = loader.loadClass("Main" true).newInstance(); . . .The network class loader subclass must define the methods
findClass
andloadClassData
to load a class from the network. Once it has downloaded the bytes that make up the class it should use the methoddefineClass
to create a class instance. A sample implementation is:class NetworkClassLoader extends ClassLoader { String host; int port; public Class findClass(String name) { byte[] b = loadClassData(name); return defineClass(name b 0 b.length); } private byte[] loadClassData(String name) { // load the class data from the connection . . . } }
@version 1.144 09160 12/1803/01 @see java.lang.Class @see java.lang.Class#newInstance() @see java.lang.ClassLoader#defineClass(byte[] int int) @see java.lang.ClassLoader#loadClass(java.lang.String boolean) @see java.lang.ClassLoader#resolveClass(java.lang.Class) @since JDK1.0
Creates a new class loader using the specified parent class loader for delegation.Class ClassLoader, Class defineClass(String, byte[], int, int)If there is a security manager its
checkCreateClassLoader
method is called. This may result in a security exception. @param parent the parent class loader @throws SecurityException if a security manager exists and itscheckCreateClassLoader
method doesn't allow creation of a new class loader. @param parent the parent class loader @see java.lang.SecurityException @see java.lang.SecurityManager#checkCreateClassLoader() @since 1.2
Converts an array of bytes into an instance of classClass ClassLoader, Class defineClass(String, byte[], int, int, ProtectionDomain)Class
. Before the Class can be used it must be resolved.This method assigns a default
ProtectionDomain
to the newly defined class. TheProtectionDomain
contains the set of permissions granted when a call toPolicy.getPolicy().getPermissions()
is made with aCodesourcecode source ofnull null
. The default domain is created on the first invocation ofdefineClass
and re-used on subsequent calls.To assign a specific
ProtectionDomain
to the class use thedefineClass
method that takes aProtectionDomain
as one of its arguments. @param name the expected name of the class ornull
if not known using '.' and not '/' as the separator and without a trailing ".class" suffix. @param b the bytes that make up the class data. The bytes in positionsoff
throughoff+len-1
should have the format of a valid class file as defined by the Java Virtual Machine Specification. @param off the start offset inb
of the class data @param len the length of the class data @return theClass
object that was created from the specified class data @exception ClassFormatError if the data did not contain a valid class @exception IndexOutOfBoundsException if eitheroff
orlen
is negative or ifoff+len
is greater thanb.length
. @exception SecurityException if an attempt is made to add this class to a package that contains classes that were signed by a different set of certificatesthenthan this class (which is unsigned) or if the class name begins with "java.". @see ClassLoader#loadClass(java.lang.String boolean) @see ClassLoader#resolveClass(java.lang.Class) @see java.security.ProtectionDomain @see java.security.Policy @see java.security.CodeSource @see java.security.SecureClassLoader @since JDK1.1
Converts an array of bytes into an instance of class Class with an optional ProtectionDomain. If the domain isClass ClassLoader, Class defineClass(byte[], int, int)null
then a default domain will be assigned to the class as specified in the documentation for byte[ int int)}. Before the class can be used it must be resolved.The first class defined in a package determines the exact set of certificates that all subsequent classes defined in that package must contain. The set of certificates for a class is obtained from the
CodeSource
within theProtectionDomain
of the class. Any classes added to that package must contain the same set of certificates or aSecurityException
will be thrown. Note that if thename
argument is null this check is not performed. You should always pass in the name of the class you are defining as well as the bytes. This ensures that the class you are defining is indeed the class you think it is.The specified class name cannot begin with "java." since all classes in the java.* packages can only be defined by the bootstrap class loader.
@exception ClassFormatError ifIf thedatanamedidparameter is notcontainnulla valid classit must be@exceptionequalIndexOutOfBoundsException if eitherto the nameoffoforthelenclassis negative or ifspecified by the byteoff+lenarrayis greater thanb otherwise ab.lengthClassFormatError is raised. @exception SecurityException if an attempt is made to addparam name the expected name of the class orthisnull
class to a packageif not known usingthat'.'contains classesand notthat'/'were signed byas the separator and without adifferenttrailingset".class"ofsuffix.certificates@paramthan this class orb the bytes thatifmake up the classnamedata.begins withThe bytes"java.".in@parampositionsnameoff
throughoff+len-1
should have thenameformat ofthea valid class@paramfilebas defined by theclassJavabytesVirtual Machine Specification. @param off the start offset inb
of the classbytesdata @param len the length of the classbytesdata @param protectionDomain the ProtectionDomain of the class @return theClass
object created from the data and optional ProtectionDomain. @exception ClassFormatError if the data did not contain a valid class @exception IndexOutOfBoundsException if eitheroff
orlen
is negative or ifoff+len
is greater thanb.length
. @exception SecurityException if an attempt is made to add this class to a package that contains classes that were signed by a different set of certificates than this class or if the class name begins with "java.".
Converts an array of bytes into an instance of classClass ClassLoader, ClassLoader getSystemClassLoader()Class
. Before the Class can be used it must be resolved. This method is deprecated in favor of the version that takes the class name as its first argument and is more secure. @param b the bytes that make up the class data. The bytes in positionsoff
throughoff+len-1
should have the format of a valid class file as defined by the Java Virtual Machine Specification. @param off the start offset inb
of the class data @param len the length of the class data @return theClass
object that was created from the specified class data @exception ClassFormatError if the data did not contain a valid class @exception IndexOutOfBoundsException if eitheroff
orlen
is negative or ifoff+len
is greater thanb.length
. @see ClassLoader#loadClass(java.lang.String boolean) @see ClassLoader#resolveClass(java.lang.Class) @deprecated Replaced by defineClass(java.lang.String byte[] int int)
Returns the system class loader for delegation. This is the default delegation parent for newClassLoader
instances and is typically the class loader used to start the application.This method is first invoked early in the runtime's startup sequence at which point it creates the system class loader and sets it as the context class loader of the invoking Thread.
The default system class loader is an implementation-dependent instance of this class.
If the system property java.system.class.loader is defined when this method is first invoked then the value of that property is taken to be the name of a class that will be returned as the system class loader. The class is loaded using the default system class loader and must define a public constructor that takes a single parameter of type ClassLoader which is used as the delegation parent. An instance is then created using this constructor with the default system class loader as the parameter. The resulting class loader is defined to be the system class loader.
If a security manager is present and the caller's class loader is not null and the caller's class loader is not the same as or an ancestor of the system class loader then this method calls the security manager's
checkPermission
method with aRuntimePermission("getClassLoader")
permission to ensure it's ok to access the system class loader. If not aSecurityException
will be thrown. @return the systemClassLoader
for delegation ornull
if none @throws SecurityException if a security manager exists and itscheckPermission
method doesn't allow access to the system class loader. @throws IllegalStateException if invoked recursively during the construction of the class loader specified by thejava.system.class.loader
property. @throws Error if the system property java.system.class.loader is defined but the named class could not be loaded the provider class does not define the required constructor or an exception is thrown by that constructor when it is invoked. The underlying cause of the error can be retrieved via the Throwable#getCause() method. @see SecurityManager#checkPermission @see java.lang.RuntimePermission @sincerevised 1.24
Thrown when an application tries to load in a class through its string name using:Class ClassNotFoundException, Throwable getException()
- The
forName
method in classClass
.- The
findSystemClass
method in classClassLoader
.- The
loadClass
method in classClassLoader
.but no definition for the class with the
specifedspecified name could be found.As of release 1.4 this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The "optional exception that was raised while loading the class" that may be provided at construction time and accessed via the #getException() method is now known as the cause and may be accessed via the Throwable#getCause() method as well as the aforementioned "legacy method." @author unascribed @version 1.
13 0217 12/0203/0001 @see java.lang.Class#forName(java.lang.String) @see java.lang.ClassLoader#findSystemClass(java.lang.String) @see java.lang.ClassLoader#loadClass(java.lang.String boolean) @since JDK1.0
Returns the exception that was raised if an error occurred while attempting to load the class. Otherwise returns null.This method predates the general-purpose exception chaining facility. The Throwable#getCause() method is now the preferred means of obtaining this information. @return the
Exception
that was raised while loading a class @since 1.2
Thrown to indicate that theclone
method in classObject
has been called to clone an object but that the object's class does not implement theCloneable
interface.Applications that override the
clone
method can also throw this exception to indicate that an object could not or should not be cloned. @author unascribed @version 1.8 029 12/0203/0001 @see java.lang.Cloneable @see java.lang.Object#clone() @since JDK1.0
A class implements theCloneable
interface to indicate to the java.lang.Object#clone() method that it is legal for that method to make a field-for-field copy of instances of that class.
AttemptsInvokingtoObject's cloneinstancesmethod on an instance thatdodoes not implement theCloneable
interfaceresultresults in the exceptionCloneNotSupportedException
being thrown.
TheBy convention classes that implement this interface should overrideCloneableObject.clone (which is protected) with a public method. See java.lang.Object#clone() for details on overriding this method.Note that this interface does not contain the clone
declaresmethod. Therefore it is not possible to clone an object merely by virtue of the fact that it implements this interface. Even if the clone method is invoked reflectively there is nomethodsguarantee that it will succeed. @author unascribed @version 1.10 0213 12/0203/0001 @see java.lang.CloneNotSupportedException @see java.lang.Object#clone() @since JDK1.0
This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering and the class's compareTo method is referred to as its natural comparison method.Class Comparable, int compareTo(Object)Lists (and arrays) of objects that implement this interface can be sorted automatically by Collections.sort (and Arrays.sort). Objects that implement this interface can be used as keys in a sorted map or elements in a sorted set without the need to specify a comparator.
A class'sThe natural ordering for a class C is said to be consistent with equals if and only if (e1.compareTo((Object)e2) == 0) has the same boolean value as e1.equals((Object)e2) for every e1 and e2 of class C. Note that null is not an instance of any class and e.compareTo(null) should throw a NullPointerException even though e.equals(null) returns false.It is strongly recommended (though not required) that natural orderings be consistent with equals. This is so because sorted sets (and sorted maps) without explicit comparators behave "strangely" when they are used with elements (or keys) whose natural ordering is inconsistent with equals. In particular such a sorted set (or sorted map) violates the general contract for set (or map) which is defined in terms of the equals
operationmethod.For example if one adds two keys a and b such that ( a.equals((Object)b) && a.compareTo((Object)b) == 0) to a sorted set that does not use an explicit comparator the second add operation returns false (and the size of the sorted set does not increase) because a and b are equivalent from the sorted set's perspective.
Virtually all Java core classes that implement comparable have natural orderings that are consistent with equals. One exception is java.math.BigDecimal whose natural ordering equates
BigDecimalsBigDecimal objects with equal values and different precisions (such as 4.0 and 4.00).For the mathematically inclined the relation that defines the natural ordering on a given class C is:
{(x y) such that x.compareTo((Object)y) <= 0}.The quotient for this total order is:{(x y) such that x.compareTo((Object)y) == 0}.It follows immediately from the contract for compareTo that the quotient is an equivalence relation on C and that the natural ordering is a total order on C. When we say that a class's natural ordering is consistent with equals we mean that the quotient for the natural ordering is the equivalence relation defined by the class's equals(Object) method:{(x y) such that x.equals((Object)y)}.@author Josh Bloch @version 1.13 0218 12/0203/0001 @see java.util.Comparator @see java.util.Collections#sort(java.util.List) @see java.util.Arrays#sort(Object[]) @see java.util.SortedSet @see java.util.SortedMap @see java.util.TreeSet @see java.util.TreeMap @since 1.2
Compares this object with the specified object for order. Returns a negative integer zero or a positive integer as this object is less than equal to or greater than the specified object.In the foregoing description the notation sgn(expression) designates the mathematical signum function which is defined to return one of -1 0 or 1 according to whether the value of expression is negative zero or positive. The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)
The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.
Finally the implementer must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)) for all z.
It is strongly recommended but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals." @param o the Object to be compared. @return a negative integer zero or a positive integer as this object is less than equal to or greater than the specified object. @throws ClassCastException if the specified object's type prevents it from being compared to this Object.
TheClass Compiler, Object command(Object)Compiler
class is provided to support Java-to-native-code compilers and related services. By design theCompiler
class does nothing; it serves as a placeholder for a JIT compiler implementation.When the Java Virtual Machine first starts it determines if the system property
java.compiler
exists. (System properties are accessible throughgetProperty
and a method defined by theSystem
class.) If so it is assumed to be the name of a library (with a platform-dependent exact location and type); theloadLibrary
method in classSystem
is called to load that library. If this loading succeeds the function namedjava_lang_Compiler_start()
in that library is called.If no compiler is available these methods do nothing. @author Frank Yellin @version 1.
15 0217 12/0203/0001 @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String) @see java.lang.System#loadLibrary(java.lang.String) @since JDK1.0
Examines the argument type and its fields and perform some documented operation. No specific operations are required. @param any an argument. @return a compiler-specific value orClass Compiler, boolean compileClass(Class)null
if no compiler is available. @exception NullPointerException ifany
isnull
.
Compiles the specified class. @param clazz a class. @returnClass Compiler, boolean compileClasses(String)true
if the compilation succeeded;false
if the compilation failed or no compiler is available. @exception NullPointerException ifclazz
isnull
.
Compiles all classes whose name matches the specified string. @param string the name of the classes to compile. @returntrue
if the compilation succeeded;false
if the compilation failed or no compiler is available. @exception NullPointerException ifstring
isnull
.
TheClass Double, constructor Double(String)Double
class wraps a value of the primitive typedouble
in an object. An object of typeDouble
contains a single field whose type isdouble
.In addition this class provides several methods for converting a
double
to aString
and aString
to adouble
as well as other constants and methods useful when dealing with adouble
. @author Lee Boynton @author Arthur van Hoff @version 1.63 0279 12/0203/0001 @since JDK1.0
Constructs a newly allocatedClass Double, byte byteValue()Double
object that represents the floating-point value of typedouble
represented by the string. The string is converted to adouble
value as if by thevalueOf
method. @param s a string to be converted to aDouble
. @exception NumberFormatException if the string does not contain a parsable number. @see java.lang.Double#valueOf(java.lang.String)
Returns the value of thisClass Double, int compareTo(Double)Double
as abyte
(by casting to abyte
). @return thedouble
value represented by this object converted to typebyte
@since JDK1.1
Compares twoClass Double, int compareTo(Object)DoublesDouble
objects numerically. There are two ways in which comparisons performed by this method differ from those performed by the Java language numerical comparison operators (< <= == >= >
) when applied to primitivedoublesdouble
values:This ensures that
Double.NaN
is considered by this method to be equal to itself and greater than all otherdouble
values (includingDouble.POSITIVE_INFINITY
).0.0d
is considered by this method to be greater than-0.0d
.Double.compareTo(Object)
(whichinheritsforwards its behaviorfromto this method) obeys the general contract forComparable.compareTo
and that the natural order onDoublesDouble
s istotalconsistent with equals. @param anotherDouble theDouble
to be compared. @return the value0
ifanotherDouble
is numerically equal to thisDouble
; a value less than0
if thisDouble
is numerically less thananotherDouble
; and a value greater than0
if thisDouble
is numerically greater thananotherDouble
. @since 1.2 @see Comparable#compareTo(Object)
Compares thisClass Double, long doubleToLongBits(double)Double
object to anotherObjectobject. If theObjectobject is aDouble
this function behaves likecompareTo(Double)
. Otherwise it throws aClassCastException
(asDoublesDouble
objects are comparable only to otherDoublesDouble
objects). @param o theObject
to be compared. @return the value0
if the argument is aDouble
numerically equal to thisDouble
; a value less than0
if the argument is aDouble
numerically greater than thisDouble
; and a value greater than0
if the argument is aDouble
numerically less than thisDouble
. @exceptionClassCastException
if the argument is not aDouble
. @see java.lang.Comparable @since 1.2
Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.Class Double, long doubleToRawLongBits(double)Bit 63 (the bit that is selected by the mask
0x8000000000000000L
) represents the sign of the floating-point number. Bits 62-52 (the bits that are selected by the mask0x7ff0000000000000L
) represent the exponent. Bits 51-0 (the bits that are selected by the mask0x000fffffffffffffL
) represent the significand (sometimes called the mantissa) of the floating-point number.If the argument is positive infinity the result is
0x7ff0000000000000L
.If the argument is negative infinity the result is
0xfff0000000000000L
.If the argument is NaN the result is
0x7ff8000000000000L
.In all cases the result is a
long
integer that when given to the #longBitsToDouble(long) method will produce a floating-point valueequal tothe same as the argument todoubleToLongBits
(except all NaN values are collapsed to a single "canonical" NaN value). @param value adouble
precision floating-point number. @return the bits that represent the floating-point number.
Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout preserving Not-a-Number (NaN) values.Class Double, double doubleValue()Bit 63 (the bit that is selected by the mask
0x8000000000000000L
) represents the sign of the floating-point number. Bits 62-52 (the bits that are selected by the mask0x7ff0000000000000L
) represent the exponent. Bits 51-0 (the bits that are selected by the mask0x000fffffffffffffL
) represent the significand (sometimes called the mantissa) of the floating-point number.If the argument is positive infinity the result is
0x7ff0000000000000L
.If the argument is negative infinity the result is
0xfff0000000000000L
.If the argument is NaN the result is the
long
integer representing the actual NaN value. Unlike thedoubleToLongBits
methoddoubleToRawLongBits
does not collapse all the bit patterns encoding a NaNvaluesto a single "canonical" NaN value.In all cases the result is a
long
integer that when given to the #longBitsToDouble(long) method will produce a floating-point valueequalthe sametoas the argument todoubleToRawLongBits
. @param value adouble
precision floating-point number. @return the bits that represent the floating-point number.
Returns theClass Double, boolean equals(Object)double
value of thisDouble
object. @return thedouble
value represented by this object.
Compares this object against the specified object. The result isClass Double, float floatValue()true
if and only if the argument is notnull
and is aDouble
object that represents adouble
that has theidentical bit pattern to the bitsamepattern ofvalue as thedouble
represented by this object. For this purpose twodouble
values are considered to be the same if and only if the method #doubleToLongBits(double) returns thesameidenticallong
value when applied to each.Note that in most cases for two instances of class
Double
d1
andd2
the value ofd1.equals(d2)
istrue
if and only ifd1.doubleValue() == d2.doubleValue()also has the value
true
. However there are two exceptions:This definition allows
- If
d1
andd2
both representDouble.NaN
then theequals
method returnstrue
even thoughDouble.NaN==Double.NaN
has the valuefalse
.- If
d1
represents+0.0
whiled2
represents-0.0
or vice versa theequal
test has the valuefalse
even though+0.0==-0.0
has the valuetrue
.hashtableshash tables to operate properly.@param obj the object to compare with. @returntrue
if the objects are the same;false
otherwise. @see java.lang.Double#doubleToLongBits(double)
Returns theClass Double, int hashCode()float
value of thisDouble
object. @return thedouble
value represented by this objectisconverted to typefloat
and the result of the conversion is returned.@since JDK1.0
Returns aClass Double, int intValue()hashcodehash code for thisDouble
object. The result is the exclusive OR of the two halves of thelong
integer bit representation exactly as produced by the method #doubleToLongBits(double) of the primitivedouble
value represented by thisDouble
object. That is thehashcodehash code is the value of the expression:where(int)(v^(v>>>32))
v
is defined by:@return along v = Double.doubleToLongBits(this.doubleValue());hash code
value for this object.
Returns theClass Double, boolean isInfinite()integervalue of thisDouble
as anint
(by casting toantypeint
). @return thedouble
value represented by this objectisconverted to typeint
and the result of the conversion is returned.
ReturnsClass Double, boolean isInfinite(double)true
if thisDouble
value is infinitely large in magnitudefalse
otherwise. @returntrue
if the value represented by this object is positive infinity or negative infinity;false
otherwise.
ReturnsClass Double, boolean isNaN()true
if the specified number is infinitely large in magnitudefalse
otherwise. @param v the value to be tested. @returntrue
if the value of the argument is positive infinity or negative infinity;false
otherwise.
ReturnsClass Double, boolean isNaN(double)true
if thisDouble
value isthe speciala Not-a-Number (NaN)valuefalse
otherwise. @returntrue
if the value represented by this object is NaN;false
otherwise.
ReturnsClass Double, double longBitsToDouble(long)true
if the specified number isthe speciala Not-a-Number (NaN) valuefalse
otherwise. @param v the value to be tested. @returntrue
if the value of the argument is NaN;false
otherwise.
Returns theClass Double, long longValue()double
value corresponding to a given bit-floatrepresentionrepresentation. The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "doubleprecisionformat" bit layout.That floating-point value is returned as the result.If the argument is
0x7ff0000000000000L
the result is positive infinity.If the argument is
0xfff0000000000000L
the result is negative infinity.If the argument is any value in the range
0x7ff0000000000001L
through0x7fffffffffffffffL
or in the range0xfff0000000000001L
through0xffffffffffffffffL
the result is a NaN.AllNo IEEE 754NaN values offloating-pointtypeoperationdoubleprovidedare in effect lumped together by the Java programming language into a single value called NaNby Java can distinguish between two NaN values of the same type with different bit patterns. Distinct values of NaN are onlyaccessibledistinguishable by use of theDouble.doubleToRawLongBits
method.In all other cases let s e and m be three values that can be computed from the argument:
Then the floating-point result equals the value of the mathematical expression s&int s = ((bits >> 63) == 0) 1 : -1; int e = (int)((bits >> 52) & 0x7ffL); long m = (e == 0) (bits & 0xfffffffffffffL) << 1 : (bits & 0xfffffffffffffL) | 0x10000000000000L;#183middot;m·middot;2e-1075. @param bits anylong
integer. @return thedouble
floating-point value with the same bit pattern.
Returns theClass Double, double parseDouble(String)longvalue of thisDouble
as along
(by casting toatypelong
). @return thedouble
value represented by this objectisconverted to typelong
and the result of the conversion is returned.
Returns a newClass Double, short shortValue()double
initialized to the value represented by the specifiedString
as performed by thevalueOf
method of classDouble
. @param s the string to be parsed. @return thedouble
value represented by the string argument. @exception NumberFormatException if the string does not contain a parsabledouble
. @see java.lang.Double#valueOf(String) @since 1.2
Returns the value of thisClass Double, String toString()Double
as ashort
(by casting to ashort
). @return thedouble
value represented by this object converted to typeshort
@since JDK1.1
Returns aClass Double, String toString(double)Stringstring representation of thisDouble
object. The primitivedouble
value represented by this object is converted to a string exactly as if by the methodtoString
of one argument. @return aString
representation of this object. @see java.lang.Double#toString(double)
Class Double, Double valueOf(String)CreatesReturns a string representation of thedouble
argument. All characters mentioned below are ASCII characters.How many digits must be printed for the fractional part of m or a There must be at least one digit to represent the fractional part and beyond that as many but only as many more digits as are needed to uniquely distinguish the argument value from adjacent values of type
- If the argument is NaN the result is the string
""NaN
"".- Otherwise the result is a string that represents the sign and magnitude (absolute value) of the argument. If the sign is negative the first character of the result is '
-
' ('); if the sign is positive no sign character appears in the result. As for the magnitude m:
-'\u002D'
- If m is infinity it is represented by the characters
"Infinity"
; thus positive infinity produces the result"Infinity"
and negative infinity produces the result"-Infinity"
.- If m is zero it is represented by the characters
"0.0"
; thus negative zero produces the result"-0.0"
and positive zero produces the result"0.0"
.- If m is greater than or equal to 10-3 but less than 107 then it is represented as the integer part of m in decimal form with no leading zeroes followed by '
.
' (') followed by one or more decimal digits representing the fractional part of m.
.'\u002E'- If m is less than 10-3 or
not lessgreater than or equal to 107 then it is represented in so-called "computerized scientific notation." Let n be the unique integer such that 10n <= m < 10n+1; then let a be the mathematically exact quotient of m and 10n so that 1 <= a < 10. The magnitude is then represented as the integer part of a as a single decimal digit followed by '.
' (') followed by decimal digits representing the fractional part of a followed by the letter '
.'\u002E'E
' (') followed by a representation of n as a decimal integer as produced by the method Integer#toString(int)
E'\u0045'double
. That is suppose that x is the exact mathematical value represented by the decimal representation produced by this method for a finite nonzero argument d. Then d must be thedouble
value nearest to x; or if twodouble
values are equally close to x then d must be one of them and the least significant bit of the significand of d must be0
.To create localized string representations of a floating-point value use subclasses of java.text.NumberFormat @param d the
double
to be converted. @return a string representation of the argument.
Returns aClass Double, double MAX_VALUEnewDouble
objectinitialized toholding thedouble
value represented by thespecified string. Theargument strings
is interpreted as the representation of a floating-point value and a Double object representing that value is created and returned.If
s
isnull
then aNullPointerException
is thrown.Leading and trailing whitespace characters in
s
are ignored. The rest ofs
should constitute a FloatValue as described by the lexical rule:where Sign and FloatingPointLiteral are as defined inFloatValue:
- Signopt
NaN
- Signopt
Infinity
- Signopt FloatingPointLiteral
#§3.10.2 of the Java Language Specification. Ifits
does not have the form of a FloatValue then aNumberFormatException
is thrown. Otherwiseits
is regarded as representing an exact decimal value in the usual "computerized scientific notation"; this exact decimal value is then conceptually converted to an "infinitely precise" binary value that is then rounded to typedouble
by the usual round-to-nearest rule of IEEE 754 floating-point arithmetic which includes preserving the sign of a zero value. Finally anewDouble
objectof classrepresenting thisvalue is
Doubledoublecreatedreturned.to represent theTo interpret
doublelocalized string representations of a floating-point value use subclasses of java.text.NumberFormat @param s the string to be parsed. @return anewly constructedDouble
initialized toobject holding the value represented by thestringString
argument. @exception NumberFormatException if the string does not contain a parsable number.
Class Double, double MIN_VALUETheA constant holding the largest positive finite value of typedouble
. It is equal to the value returned by:Double.longBitsToDouble(0x7fefffffffffffffL)
.
Class Double, double NEGATIVE_INFINITYTheA constant holding the smallest positive nonzero value of typedouble
. It is equal to the value returned byDouble.longBitsToDouble(0x1L)
.
Class Double, double NaNTheA constant holding the negative infinity of typedouble
. It is equal to the value returned byDouble.longBitsToDouble(0xfff0000000000000L)
.
A constant holding a Not-a-Number (NaN) value of typeClass Double, double POSITIVE_INFINITYdouble
. It isequalequivalent to the value returned byDouble.longBitsToDouble(0x7ff8000000000000L)
.
Class Double, Class TYPETheA constant holding the positive infinity of typedouble
. It is equal to the value returned byDouble.longBitsToDouble(0x7ff0000000000000L)
.
TheClass
objectinstance representing the primitive typedouble
. @since JDK1.1
AnClass Error, constructor Error()Error
is a subclass ofThrowable
that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. TheThreadDeath
error though a "normal" condition is also a subclass ofError
because most applications should not try to catch it.A method is not required to declare in its
throws
clause any subclasses ofError
that might be thrown during the execution of the method but not caught since these errors are abnormal conditions that should never occur. @author Frank Yellin @version 1.12 0214 12/0203/0001 @see java.lang.ThreadDeath @since JDK1.0
ConstructsClass Error, constructor Error(String)anaErrornew error withnonull
asspecifiedits detail message. The cause is not initialized and may subsequently be initialized by a call to #initCause
Constructsan Errora new error with the specified detail message. The cause is not initialized and may subsequently be initialized by a call to #initCause @paramsmessage the detail message. The detail message is saved for later retrieval by the #getMessage() method.
The classClass Exception, constructor Exception()Exception
and its subclasses are a form ofThrowable
that indicates conditions that a reasonable application might want to catch. @author Frank Yellin @version 1.27 0229 12/0203/0001 @see java.lang.Error @since JDK1.0
ConstructsClass Exception, constructor Exception(String)anaExceptionnew exception withnonull
asspecifiedits detail message. The cause is not initialized and may subsequently be initialized by a call to #initCause
ConstructsanaExceptionnew exception with the specified detail message. The cause is not initialized and may subsequently be initialized by a call to #initCause @paramsmessage the detail message. The detail message is saved for later retrieval by the #getMessage() method.
Signals that an unexpected exception has occurred in a static initializer. AnClass ExceptionInInitializerError, constructor ExceptionInInitializerError()ExceptionInInitializerError
is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable.As of release 1.4 this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The "saved throwable object" that may be provided at construction time and accessed via the #getException() method is now known as the cause and may be accessed via the Throwable#getCause() method as well as the aforementioned "legacy method." @author Frank Yellin @version 1.
11 0215 12/0203/0001 @since JDK1.1
Constructs anClass ExceptionInInitializerError, Throwable getException()ExceptionInInitializerError
withnull
as its detail message string and with no savedthowablethrowable object. A detail message is a String that describes this particular exception.
Returns the exception that occurred during a static initialization that caused thisErrorerror to be created.This method predates the general-purpose exception chaining facility. The Throwable#getCause() method is now the preferred means of obtaining this information. @return the saved throwable object of this
ExceptionInInitializerError
ornull
if thisExceptionInInitializerError
has no saved throwable object.
TheClass Float, constructor Float(double)Float
class wraps a value of primitive typefloat
in an object. An object of typeFloat
contains a single field whose type isfloat
.In addition this class provides several methods for converting a
float
to aString
and aString
to afloat
as well as other constants and methods useful when dealing with afloat
. @author Lee Boynton @author Arthur van Hoff @version 1.60 0277 12/0203/0001 @since JDK1.0
Constructs a newly allocatedClass Float, byte byteValue()Float
object that represents the argument converted to typefloat
. @param value the value to be represented by theFloat
.
Returns the value of thisClass Float, int compareTo(Float)Float
as abyte
(by casting to abyte
). @sincereturnJDK1.1thefloat
value represented by this object converted to typebyte
Compares twoClass Float, int compareTo(Object)FloatsFloat
objects numerically. There are two ways in which comparisons performed by this method differ from those performed by the Java language numerical comparison operators (< <= == >= >
) when applied to primitivefloatsfloat
values:This ensures that
Float.NaN
is considered by this method to be equal to itself and greater than all otherfloat
values (includingFloat.POSITIVE_INFINITY
).0.0f
is considered by this method to be greater than-0.0f
.Float.compareTo(Object)
(whichinheritsforwards its behaviorfromto this method) obeys the general contract forComparable.compareTo
and that the natural order onFloatsFloat
s istotalconsistent with equals. @param anotherFloat theFloat
to be compared. @return the value0
ifanotherFloat
is numerically equal to thisFloat
; a value less than0
if thisFloat
is numerically less thananotherFloat
; and a value greater than0
if thisFloat
is numerically greater thananotherFloat
. @since 1.2 @see Comparable#compareTo(Object)
Compares thisClass Float, double doubleValue()Float
object to anotherObjectobject. If theObjectobject is aFloat
this function behaves likecompareTo(Float)
. Otherwise it throws aClassCastException
(asFloatsFloat
objects are comparable only to otherFloatsFloat
objects). @param o theObject
to be compared. @return the value0
if the argument is aFloat
numerically equal to thisFloat
; a value less than0
if the argument is aFloat
numerically greater than thisFloat
; and a value greater than0
if the argument is aFloat
numerically less than thisFloat
. @exceptionClassCastException
if the argument is not aFloat
. @see java.lang.Comparable @since 1.2
Returns theClass Float, boolean equals(Object)double
value of thisFloat
object. @return thefloat
value represented by this object is converted to typedouble
and the result of the conversion is returned.
Compares this object againstClass Float, int floatToIntBits(float)some otherthe specified object. The result istrue
if and only if the argument is notnull
and is aFloat
object that represents afloat
that has the identical bit pattern towith thebit pattern ofsame value as thefloat
represented by this object. For this purpose twofloat
values are considered to be the same if and only if the method #floatToIntBits(float) returns thesameidenticalint
value when applied to each.Note that in most cases for two instances of class
Float
f1
andf2
the value off1.equals(f2)
istrue
if and only iff1.floatValue() == f2.floatValue()also has the value
true
. However there are two exceptions:This definition allows
- If
f1
andf2
both representFloat.NaN
then theequals
method returnstrue
even thoughFloat.NaN==Float.NaN
has the valuefalse
.- If
f1
represents+0.0f
whilef2
represents-0.0f
or vice versa theequal
test has the valuefalse
even though0.0f==-0.0f
has the valuetrue
.hashtableshash tables to operate properly. @param obj the object to be compared @returntrue
if the objects are the same;false
otherwise. @see java.lang.Float#floatToIntBits(float)
ReturnsClass Float, int floatToRawIntBits(float)the bit represention of a single-float value. The result isa representation of the specified floating-pointargumentvalue according to the IEEE 754 floating-point "singleprecisionformat" bit layout.Bit 31 (the bit that is selected by the mask
0x80000000
) represents the sign of the floating-point number. Bits 30-23 (the bits that are selected by the mask0x7f800000
) represent the exponent. Bits 22-0 (the bits that are selected by the mask0x007fffff
) represent the significand (sometimes called the mantissa) of the floating-point number.If the argument is positive infinity the result is
0x7f800000
.If the argument is negative infinity the result is
0xff800000
.If the argument is NaN the result is
0x7fc00000
.In all cases the result is an integer that when given to the #intBitsToFloat(int) method will produce a floating-point value
equalthe sametoas the argument tofloatToIntBits
(except all NaN values are collapsed to a single "canonical" NaN value). @param value a floating-point number. @return the bits that represent the floating-point number.
ReturnsClass Float, float floatValue()the bit represention of a single-float value. The result isa representation of the specified floating-pointargumentvalue according to the IEEE 754 floating-point "singleprecisionformat" bit layout preserving Not-a-Number (NaN) values.Bit 31 (the bit that is selected by the mask
0x80000000
) represents the sign of the floating-point number. Bits 30-23 (the bits that are selected by the mask0x7f800000
) represent the exponent. Bits 22-0 (the bits that are selected by the mask0x007fffff
) represent the significand (sometimes called the mantissa) of the floating-point number.If the argument is positive infinity the result is
0x7f800000
.If the argument is negative infinity the result is
0xff800000
.If the argument is NaN the result is the integer representing the actual NaN value. Unlike the
floatToIntBits
methodintToRawIntBits
does not collapse all the bit patterns encoding a NaNvaluesto a single "canonical" NaN value.In all cases the result is an integer that when given to the #intBitsToFloat(int) method will produce a floating-point value
equalthetosame as the argument tofloatToRawIntBits
. @param value a floating-point number. @return the bits that represent the floating-point number.
Returns theClass Float, int hashCode()float
value of thisFloat
object. @return thefloat
value represented by this object.
Returns aClass Float, float intBitsToFloat(int)hashcodehash code for thisFloat
object. The result is the integer bit representation exactly as produced by the method #floatToIntBits(float) of the primitivefloat
value represented by thisFloat
object. @return a hash code value for this object.
Returns theClass Float, int intValue()single-float
value corresponding to a given bit represention. The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "singleprecisionformat" bit layout.If the argument is
0x7f800000
the result is positive infinity.If the argument is
0xff800000
the result is negative infinity.If the argument is any value in the range
0x7f800001
through0x7fffffff
or in the range0xff800001
through0xffffffff
the result is a NaN.AllNo IEEE 754NaN values of typefloating-pointfloatoperationare in effect lumped together by the Java programming language into a singleprovided by Java can distinguish between two NaN values of the same typefloatwithvalue called NaNdifferent bit patterns. Distinct values of NaN are onlyaccessibledistinguishable by use of theFloat.floatToRawIntBits
method.In all other cases let s e and m be three values that can be computed from the argument:
Then the floating-point result equals the value of the mathematical expression s&int s = ((bits >> 31) == 0) 1 : -1; int e = ((bits >> 23) & 0xff); int m = (e == 0) (bits & 0x7fffff) << 1 : (bits & 0x7fffff) | 0x800000;#183middot;m·middot;2e-150. @param bits an integer. @return thesingle-formatfloat
floating-point value with the same bit pattern.
Returns theClass Float, boolean isInfinite()integervalue of thisFloat
as anint
(by casting toantypeint
). @return thefloat
value represented by this object converted to typeint
and the result of the conversion is returned.
ReturnsClass Float, boolean isInfinite(float)true
if thisFloat
value is infinitely large in magnitudefalse
otherwise. @returntrue
if the value represented by this object is positive infinity or negative infinity;false
otherwise.
ReturnsClass Float, boolean isNaN()true
if the specified number is infinitely large in magnitudefalse
otherwise. @param v the value to be tested. @returntrue
if the argument is positive infinity or negative infinity;false
otherwise.
ReturnsClass Float, boolean isNaN(float)true
if thisFloat
value is a Not-a-Number (NaN)false
otherwise. @returntrue
if the value represented by this object is NaN;false
otherwise.
ReturnsClass Float, long longValue()true
if the specified number isthe speciala Not-a-Number (NaN) valuefalse
otherwise. @param v the value to be tested. @returntrue
if the argument is NaN;false
otherwise.
ReturnsClass Float, float parseFloat(String)the longvalue of thisFloat
as along
(by casting toatypelong
). @return thefloat
value represented by this objectisconverted to typelong
and the result of the conversion is returned.
Returns a newClass Float, short shortValue()float
initialized to the value represented by the specifiedString
as performed by thevalueOf
method of class. @param s the string to be parsed. @return the
DoubleFloatfloat
value represented by the string argument. @exception NumberFormatException if the string does not contain a parsablefloat
. @see java.lang.DoubleFloat#valueOf(String) @since 1.2
Returns the value of thisClass Float, String toString()Float
as ashort
(by casting to ashort
). @return thefloat
value represented by this object converted to typeshort
@since JDK1.1
Returns aClass Float, String toString(float)Stringstring representation of thisFloat
object. The primitivefloat
value represented by this object is converted to aString
exactly as if by the methodtoString
of one argument. @return aString
representation of this object. @see java.lang.Float#toString(float)
Returns aClass Float, Float valueOf(String)Stringstring representationforof thespecifiedfloat
argumentvalue. Theis converted to a readable string format as follows. All charactersand characters in stringsmentioned below are ASCII characters.How many digits must be printed for the fractional part of m or a There must be at least one digit to represent the fractional part and beyond that as many but only as many more digits as are needed to uniquely distinguish the argument value from adjacent values of type
- If the argument is NaN the result is the string
""NaN
"".- Otherwise the result is a string that represents the sign and magnitude (absolute value) of the argument. If the sign is negative the first character of the result is '
-
' ('
); if the sign is positive no sign character appears in the result. As for the magnitude m:-\u002D'
- If m is infinity it is represented by the characters
"Infinity"
; thus positive infinity produces the result"Infinity"
and negative infinity produces the result"-Infinity"
.- If m is zero it is represented by the characters
"0.0"
; thus negative zero produces the result"-0.0"
and positive zero produces the result"0.0"
.- If m is greater than or equal to 10-3 but less than 107 then it is represented as the integer part of m in decimal form with no leading zeroes followed by '
.
' (.'\u002E'
) followed by one or more decimal digits representing the fractional part of m.- If m is less than 10-3 or greater than or equal to 107 then it is represented in so-called "computerized scientific notation." Let n be the unique integer such that 10n <= m < 10n+1; then let a be the mathematically exact quotient of m and 10n so that 1 <= a &
lt10lt; 10. The magnitude is then represented as the integer part of a as a single decimal digit followed by '.
' (.'\u002E'
) followed by decimal digits representing the fractional part of a followed by the letter 'E
' (E'\u0045'
) followed by a representation of n as a decimal integer as produced by the method{@link java.lang.Integer#toString(int)}
.of one argumentfloat
. That is suppose that x is the exact mathematical value represented by the decimal representation produced by this method for a finite nonzero argument f. Then f must be thefloat
value nearest to x; or if twofloat
values are equally close to x then f must be one of them and the least significant bit of the significand of f must be0
.To create localized string representations of a floating-point value use subclasses of java.text
.NumberFormat @param f the float to be converted. @return a string representation of the argument.
ReturnsClass Float, float MAX_VALUEthe floating pointavalueFloat
represented byobject holding thespecified String. The string
sfloatisvalueinterpreted asrepresented by therepresentation of a floating-point value andargumentastring
Floatsobject representing that value is created and returned.If
s
isnull
then aNullPointerException
is thrown.Leading and trailing whitespace characters in
s
are ignored. The rest ofs
should constitute a FloatValue as described by the lexical syntax rules:where Sign and FloatingPointLiteral are as defined inFloatValue:
- Signopt
NaN
- Signopt
Infinity
- Signopt FloatingPointLiteral
#§3.10.2 of the Java Language Specification. Ifits
does not have the form of a FloatValue then aNumberFormatException
is thrown. Otherwiseits
is regarded as representing an exact decimal value in the usual "computerized scientific notation"; this exact decimal value is then conceptually converted to an "infinitely precise" binary value that is then rounded to typefloat
by the usual round-to-nearest rule of IEEE 754 floating-point arithmetic which includes preserving the sign of a zero value. Finally aFloat
object representing thisfloat
value is returned.To interpret localized string representations of a floating-point value use subclasses of java
.text.NumberFormat @param s the string to be parsed. @return anewly constructedFloat
initialized toobject holding the value represented by theString
argument. @exception NumberFormatException if the string does not contain a parsable number.
Class Float, float MIN_VALUETheA constant holding the largest positive finite value of typefloat
. It is equal to the value returned byFloat.intBitsToFloat(0x7f7fffff)
.
Class Float, float NEGATIVE_INFINITYTheA constant holding the smallest positive nonzero value of typefloat
. It is equal to the value returned byFloat.intBitsToFloat(0x1)
.
Class Float, float NaNTheA constant holding the negative infinity of typefloat
. It is equal to the value returned byFloat.intBitsToFloat(0xff800000)
.
Class Float, float POSITIVE_INFINITYTheA constant holding a Not-a-Number (NaN) value of typefloat
. It isequalequivalent to the value returned byFloat.intBitsToFloat(0x7fc00000)
.
Class Float, Class TYPETheA constant holding the positive infinity of typefloat
. It is equal to the value returned byFloat.intBitsToFloat(0x7f800000)
.
TheClass
objectinstance representing the primitive typefloat
. @since JDK1.1
Thrown if an application attempts to access or modify a field or to call a method that it does not have access to.Normally this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. @author unascribed @version 1.
13 0214 12/0203/0001 @since JDK1.0
ThrownAn IllegalAccessException is thrown when an application tries toloadreflectively create an instance (other than an array) set oringet aclassfield or invoke a method but the currently executing method does not have access to the definition of the specified classbecause the class is not publicfieldand inmethodanother packageor constructor.An instance of@authorthisunascribedclass@versioncan1.12also12/03/01be@seethrownClass#newInstance()when@seeanjava.lang.reflect.Field#set(ObjectapplicationObject)tries@seetojava.lang.reflect.Field#setBoolean(Objectcreateboolean)an@seeinstancejava.lang.reflect.Field#setByte(Objectofbyte)a@seeclassjava.lang.reflect.Field#setShort(Objectusingshort)the@seenewInstancejava.lang.reflect.Field#setChar(Objectmethodchar)in@seeclassjava.lang.reflect.Field#setInt(ObjectClassint)but@seethejava.lang.reflect.Field#setLong(Objectcurrentlong)method@seedoesjava.lang.reflect.Field#setFloat(Objectnotfloat)have@seeaccessjava.lang.reflect.Field#setDouble(Objecttodouble)the@seeappropriatejava.lang.reflect.Field#get(Object)zero-argument@seeconstructorjava.lang.reflect.Field#getBoolean(Object) @authorseeunascribedjava.lang.reflect.Field#getByte(Object) @version 1see java.9 02/02/00lang.reflect.Field#getShort(Object) @see java.lang.Classreflect.Field#forNamegetChar(Object) @see java.lang.Stringreflect.Field#getInt(Object) @see java.lang.Classreflect.Field#newInstancegetLong(Object) @see java.lang.ClassLoaderreflect.Field#findSystemClassgetFloat(Object) @see java.lang.Stringreflect.Field#getDouble(Object) @see java.lang.ClassLoaderreflect.Method#loadClassinvoke(Object Object[]) @see java.lang.String booleanreflect.Constructor#newInstance(Object[]) @since JDK1.0
Thrown to indicate that a method has been passed an illegal or inappropriate argument. @author unascribed @version 1.17 0218 12/0203/0001 @see java.lang.Thread#setPriority(int) @since JDK1.0
Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads waiting on an object's monitor without owning the specified monitor. @author unascribed @version 1.9 0210 12/0203/0001 @see java.lang.Object#notify() @see java.lang.Object#notifyAll() @see java.lang.Object#wait() @see java.lang.Object#wait(long) @see java.lang.Object#wait(long int) @since JDK1.0
Signals that a method has been invoked at an illegal or inappropriate time. In other words the Java environment or Java application is not in an appropriate state for the requested operation. @author Jonni Kanerva @version 1.9 0210 12/0203/0001 @since JDK1.1
Thrown to indicate that a thread is not in an appropriate state for the requested operation. See for example thesuspend
andresume
methods in classThread
. @author unascribed @version 1.18 0219 12/0203/0001 @see java.lang.Thread#resume() @see java.lang.Thread#suspend() @since JDK1.0
Thrown when an incompatible class change has occurred to some class definition. The definition of some class on which the currently executing method depends has since changed. @author unascribed @version 1.15 0216 12/0203/0001 @since JDK1.0
Thrown to indicate that an index of some sort (such as to an array to a string or to a vector) is out of range.Applications can subclass this class to indicate similar exceptions. @author Frank Yellin @version 1.
8 029 12/0203/0001 @since JDK1.0
This class extends ThreadLocal to provide inheritance of values from parentClass InheritableThreadLocal, Object childValue(Object)Threadthread to childThreadthread: when a child thread is created the child receives initial values for allInheritableThreadLocalsinheritable thread-local variables for which the parent has values. Normally the child's values will be identical to the parent's; however the child's value can be made an arbitrary function of the parent's by overriding the childValue method in this class.
InheritableThreadLocalInheritable thread-local variables are used in preference to ordinaryThreadLocalthread-local variables when the per-thread-attribute being maintained in the variable (e.g. User ID Transaction ID) must be automatically transmitted to any child threads that are created. @author Josh Bloch and Doug Lea @version 1.10 0215 12/0203/0001 @see ThreadLocal @since 1.2
Computes the child's initial value for thisClass InheritableThreadLocal, Object get()InheritableThreadLocalinheritable thread-local variable as a function of the parent's value at the time the childThreadthread is created. This method is called from within the parent thread before the child is started.This method merely returns its input argument and should be overridden if a different behavior is desired. @param parentValue the parent thread's value @return the child thread's initial value
Returns the value in theClass InheritableThreadLocal, void set(Object)callingcurrent thread's copy of thisThreadLocalthread-local variable. Creates and initializes the copy if this is the first time the thread has called this method. @return the current thread's value of this thread-local
Sets thecallingcurrent thread'sinstancecopy of thisThreadLocalthread-local variable to thegivenspecified value. This is only used to change the value from the one assigned by the initialValue method and many applications will have no need for this functionality. @param value the value to be stored in thecallingcurrent threads' copy of thisThreadLocalthread-local.
Thrown when an application tries to use the Javanew
construct to instantiate an abstract class or an interface.Normally this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. @author unascribed @version 1.
9 0210 12/0203/0001 @since JDK1.0
Thrown when an application tries to create an instance of a class using thenewInstance
method in classClass
but the specified class object cannot be instantiated because it is an interface or is an abstract class. @author unascribed @version 1.14 0215 12/0203/0001 @see java.lang.Class#newInstance() @since JDK1.0
TheClass Integer, constructor Integer(String)Integer
class wraps a value of the primitive typeint
in an object. An object of typeInteger
contains a single field whose type isint
.In addition this class provides several methods for converting an
int
to aString
and aString
to anint
as well as other constants and methods useful when dealing with anint
. @author Lee Boynton @author Arthur van Hoff @version 1.64 0273 12/0903/01 @since JDK1.0
Constructs a newly allocatedClass Integer, constructor Integer(int)Integer
object that represents theint
valuerepresentedindicated by thestringString
parameter. The string is converted to anint
value in exactly the manner used by theparseInt
method for radix 10. @param s theString
to be converted to anInteger
. @exception NumberFormatException if theString
does not contain a parsable integer. @see java.lang.Integer#parseInt(java.lang.String int)
Constructs a newly allocatedClass Integer, byte byteValue()Integer
object that represents theprimitivespecifiedint
argumentvalue. @param value the value to be represented by theInteger
object.
Returns the value of thisClass Integer, int compareTo(Integer)Integer
as abyte
.@since JDK1.1
Compares twoClass Integer, int compareTo(Object)IntegersInteger
objects numerically. @param anotherInteger theInteger
to be compared. @return the value0
ifthe argumentthisInteger
is equal tothisthe argumentInteger; a value less than
0
if thisInteger
is numerically less than theIntegerargumentInteger
; and a value greater than0
if thisInteger
is numerically greater than theIntegerargumentInteger
(signed comparison). @since 1.2
Compares thisClass Integer, Integer decode(String)Integer
object to anotherObjectobject. If theObjectobject isaanInteger
this function behaves likecompareTo(Integer)
. Otherwise it throws aClassCastException
(asIntegersInteger
are comparableobjects are only comparable to otherIntegersInteger
objects). @param o theObject
to be compared. @return the value0
if the argument is aInteger
numerically equal to thisInteger
; a value less than0
if the argument is aInteger
numerically greater than thisInteger
; and a value greater than0
if the argument is aInteger
numerically less than thisInteger
. @exceptionClassCastException
if the argument is not anInteger
. @see java.lang.Comparable @since 1.2
Decodes aClass Integer, double doubleValue()String
into anInteger
. Accepts decimal hexadecimal and octal numbersinnumbers given by the followingformatsgrammar:[-]DecimalNumeral HexDigitsdecimal
constant- DecodableString:
[-]- Signopt DecimalNumeral
- Signopt
0x
hexHexDigits- Signopt
constant0X
[-]HexDigits- Signopt
#
HexDigits- Signopt
hex0
constantOctalDigits
- Sign:
[-
] 0octalconstantand OctalDigits are defined in §3.10.1 of the Java Language Specification.The
constantsequence of characters following an (optional) negative sign and/or"radix specifier"("0x
" "0X
" "#
" or leading zero) is parsed as by theInteger.parseInt
method with thespecifiedindicated radix (10816 or168). Thisconstantsequence of characters mustberepresent a positive value or a NumberFormatException willresultbe thrown. The result ismade negativenegated if first character of the specifiedString
is thenegativeminus sign. No whitespace characters are permitted in theString
. @param nm theString
to decode. @returntheaInteger
represented byobject holding thespecifiedint
string.value represented bynm
@exception NumberFormatException if theString
does not contain a parsable integer. @see java.lang.Integer#parseInt(java.lang.String int) @since 1.2
Returns the value of thisClass Integer, float floatValue()Integer
as adouble. @return the int value represented by this object is converted to typedouble
and the result of the conversion is returned.
Returns the value of thisClass Integer, Integer getInteger(String)Integer
as afloat. @return the int value represented by this object is converted to typefloat
and the result of the conversion is returned.
Determines the integer value of the system property with the specified name.Class Integer, Integer getInteger(String, Integer)The first argument is treated as the name of a system property. System properties are accessible through the java.lang.System#getProperty(java.lang.String) method. The string value of this property is then interpreted as an integer value and an
Integer
object representing this value is returned. Details of possible numeric formats can be found with the definition ofgetProperty
.If there is no property with the specified name if the specified name is empty or
null
or if the property does not have the correct numeric format thennull
is returned.In other words this method returns an
Integer
object equal to the value of:@param nm property name. @return thegetInteger(nm null)
Integer
value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String)
Returns the integer value of the system property with the specified name. The first argument is treated as the name of a system property. System properties are accessible throughClass Integer, Integer getInteger(String, int)getProperty a method defined bythe java.lang.System#getProperty(java.lang.String)classmethod. The string value of this property is then interpreted as an integer value as per theInteger.decode
method and anInteger
object representing this value is returned.
- If the property value begins with the two ASCII characters
0x
or the ASCII character#
not followed by a minus sign then the rest of it is parsed as a hexadecimal integer exactly asforby the method int) with radix 16.- If the property value begins with the ASCII character
0
followed by another character it is parsed as an octal integer exactly asforby the method int) with radix 8.- Otherwise the property value is parsed as a decimal integer exactly as
forby the method int) with radix 10.The second argument is the default value. The default value is returned if there is no property of the specified name if the property does not have the correct numeric format or if the specified name is empty or
null
. @param nm property name. @param val default value. @return theInteger
value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String) @see java.lang.Integer#decode
Determines the integer value of the system property with the specified name.Class Integer, int hashCode()The first argument is treated as the name of a system property. System properties are accessible through
getProperty a method defined bythe java.lang.System#getProperty(java.lang.String)classmethod. The string value of this property is then interpreted as an integer value and anInteger
object representing this value is returned. Details of possible numeric formats can be found with the definition ofgetProperty
.The second argument is the default value. An
Integer
object that represents the value of the second argument is returned if there is no property of the specified name if the property does not have the correct numeric format or if the specified name is empty ornull
.In other words this method returns an
Integer
object equal to the value of:but in practice it may be implemented in a manner such as:getInteger(nm new Integer(val))
to avoid the unnecessary allocation of anInteger result = getInteger(nm null); return (result == null) new Integer(val) : result;Integer
object when the default value is not needed. @param nm property name. @param val default value. @return theInteger
value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String)
Returns aClass Integer, int intValue()hashcodehash code for thisInteger
. @return a hash code value for this object equal to the primitiveint
value represented by thisInteger
object.
Returns the value of thisClass Integer, long longValue()Integer
as anint. @return theint
value represented by this object.
Returns the value of thisClass Integer, int parseInt(String)Integer
as along. @return the int value represented by this object that is converted to typelong
and the result of the conversion is returned.
Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits except that the first character may be an ASCII minus signClass Integer, int parseInt(String, int)'-'
('\
) to indicate a negative value. The resulting integer value is returned exactly as if the argument and the radix 10 were given as arguments to the int) method. @param s au002du002D'string.String
containing theint
representation to be parsed @return the integer value represented by the argument in decimal. @exception NumberFormatException if the string does not contain a parsable integer.
Parses the string argument as a signed integer in the radix specified by the second argument. The characters in the string must all be digits of the specified radix (as determined by whether int) returns a nonnegative value) except that the first character may be an ASCII minus signClass Integer, short shortValue()'-'
('\
) to indicate a negative value. The resulting integer value is returned.u002du002D'An exception of type
NumberFormatException
is thrown if any of the following situations occurs:
- The first argument is
null
or is a string of length zero.- The radix is either smaller than java.lang.Character#MIN_RADIX or larger than java.lang.Character#MAX_RADIX
- Any character of the string is not a digit of the specified radix except that the first character may be a minus sign
'-'
('\
) provided that the string is longer than length 1.u002du002D'- The
integervalue represented by the string is not a value of typeint
.Examples:
@param s theparseInt("0" 10) returns 0 parseInt("473" 10) returns 473 parseInt("-0" 10) returns 0 parseInt("-FF" 16) returns -255 parseInt("1100110" 2) returns 102 parseInt("2147483647" 10) returns 2147483647 parseInt("-2147483648" 10) returns -2147483648 parseInt("2147483648" 10) throws a NumberFormatException parseInt("99" 8) throws a NumberFormatException parseInt("Kona" 10) throws a NumberFormatException parseInt("Kona" 27) returns 411787String
containing the integer.representation to be parsed @param radix the radix to be used while parsings
. @return the integer represented by the string argument in the specified radix. @exception NumberFormatException if thestringString
does not contain a parsableintegerint
.
Returns the value of thisClass Integer, String toBinaryString(int)Integer
as ashort
.@since JDK1.1
Class Integer, String toHexString(int)CreatesReturns a string representation of the integer argument as an unsigned integer in base 2.The unsigned integer value is the argument plus 232 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in binary (base 2) with no extra leading
0
s. If the unsigned magnitude is zero it is represented by a single zero character'0'
('\u0030'
); otherwise the first character of the representation of the unsigned magnitude will not be the zero character. The characters'0'
('\u0030'
) and'1'
('\u0031'
) are used as binary digits. @param i an integer to be converted to a string. @return the string representation of the unsigned integer value represented by the argument in binary (base 2). @since JDK1.0.2
Class Integer, String toOctalString(int)CreatesReturns a string representation of the integer argument as an unsigned integer in base 16.The unsigned integer value is the argument plus 232 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with no extra leading
0
s. If the unsigned magnitude is zero it is represented by a single zero character'0'
('\u0030'
); otherwise the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as hexadecimal digits:These are the characters0123456789abcdef'\u0030'
through'\u0039'
and'
throughu\0039\u0061''\u0066'
. Iftheuppercase letters are desired the java.lang.String#toUpperCase() method may be called on the result:@param i an integer to be converted to a string. @return the string representation of the unsigned integer value represented by the argument in hexadecimal (base 16). @since JDK1.0.2LongInteger.toHexString(n).toUpperCase()
Class Integer, String toString()CreatesReturns a string representation of the integer argument as an unsigned integer in base8.The unsigned integer value is the argument plus 232 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in octal (base 8) with no extra leading
0
s.If the unsigned magnitude is zero it is represented by a single zero character
'0'
('\u0030'
); otherwise the first character of the representation of the unsigned magnitude will not be the zero character. Theoctal digitsfollowing characters are used as octal digits:These are the characters01234567'\u0030'
through'\u0037'
. @param i an integer to be converted to a string. @return the string representation of the unsigned integer value represented by the argument in octal (base 8). @since JDK1.0.2
Returns aClass Integer, String toString(int)String
object representing thisInteger
's value. The value is converted to signed decimal representation and returned as a string exactly as if the integer value were given as an argument to the java.lang.Integer#toString(int) method. @return a string representation of the value of this object in base 10.
Returns aClass Integer, String toString(int, int)newString
object representing the specified integer. The argument is converted to signed decimal representation and returned as a string exactly as if the argument and radix 10 were given as arguments to the int) method. @param i an integer to be converted. @return a string representation of the argument in base 10.
Class Integer, Integer valueOf(String)CreatesReturns a string representation of the first argument in the radix specified by the second argument.If the radix is smaller than
Character.MIN_RADIX
or larger thanCharacter.MAX_RADIX
then the radix10
is used instead.If the first argument is negative the first element of the result is the ASCII minus character
'-'
('\
). If the first argument is not negative no sign character appears in the result.u002du002D'The remaining characters of the result represent the magnitude of the first argument. If the magnitude is zero it is represented by a single zero character
'0'
('\u0030'
); otherwise the first character of the representation of the magnitude will not be the zero character. The following ASCII characters are used as digits:These are0123456789abcdefghijklmnopqrstuvwxyz'\u0030'
through'\u0039'
and'\u0061'
through'\
. Ifu007au007A'theradix
is N then the first N of these characters are used as radix-Ndigetsdigits in the order shown. Thus the digits for hexadecimal (radix 16) are0123456789abcdef
. If uppercase letters are desired the java.lang.String#toUpperCase() method may be called on the result:@param i an integer to be converted to a string. @param radix the radix to use in the string representation. @return a string representation of the argument in the specified radix. @see java.lang.Character#MAX_RADIX @see java.lang.Character#MIN_RADIXInteger.toString(n 16).toUpperCase()
ReturnsClass Integer, Integer valueOf(String, int)a newanInteger
objectinitializedholdingtothe value of the specifiedString
. The argument is interpreted as representing a signed decimal integer exactly as if the argument were given to the #parseInt(java.lang.String) method. The result is anInteger
object that represents the integer value specified by the string.In other words this method returns an
Integer
object equal to the value of:@param s the string to be parsed. @returnnew Integer(Integer.parseInt(s))
a newly constructedanInteger
initialized toobject holding the value represented by the string argument. @exception NumberFormatException if the string cannot be parsed as an integer.
ReturnsClass Integer, int MAX_VALUEa newanInteger
objectinitialized toholding the valueofextracted from the specifiedString
when parsed with the radix given by the second argument. The first argument is interpreted as representing a signed integer in the radix specified by the second argument exactly as if the arguments were given to the int) method. The result is anInteger
object that represents the integer value specified by the string.In other words this method returns an
Integer
object equal to the value of:@param s the string to be parsed. @param radix the radixnew Integer(Integer.parseInt(s radix))
of thetointeger represented by stringbe used in interpretings @return
a newly constructedanInteger
initialized toobject holding the value represented by the string argument in the specified radix. @exception NumberFormatException if theString
cannot be parsed as andoes not contain a parsableint
.
Class Integer, int MIN_VALUETheAlargest value of typeconstantint.holdingThe constantthe maximum valueofanthisint
field iscan have2147483647231-1.
Class Integer, Class TYPETheAsmallest value of typeconstantint.holdingThe constantthe minimum valueofanthisint
field iscan have -2147483648231.
TheClass
objectinstance representing the primitive typeint
. @since JDK1.1
Thrown to indicate some unexpected internal error has occurred in the Java Virtual Machine. @author unascribed @version 1.18 0219 12/0203/0001 @since JDK1.0
Thrown when a thread is waiting sleeping or otherwise paused for a long time and another thread interrupts it using theinterrupt
method in classThread
. @author Frank Yellin @version 1.12 0213 12/0203/0001 @see java.lang.Object#wait() @see java.lang.Object#wait(long) @see java.lang.Object#wait(long int) @see java.lang.Thread#sleep(long) @see java.lang.Thread#interrupt() @see java.lang.Thread#interrupted() @since JDK1.0
Subclasses ofLinkageError
indicate that a class has some dependency on another class; however the latter class has incompatibly changed after the compilation of the former class. @author Frank Yellin @version 1.10 0211 12/0203/0001 @since JDK1.0
TheClass Long, constructor Long(String)Long
class wraps a value of the primitive typelong
in an object. An object of typeLong
contains a single field whose type islong
.In addition this class provides several methods for converting a
long
to aString
and aString
to along
as well as other constants and methods useful when dealing with along
. @author Lee Boynton @author Arthur van Hoff @version 1.52 0262 12/0203/0001 @since JDK1.0
Constructs a newly allocatedClass Long, constructor Long(long)Long
object that represents thelong
valuerepresentedindicated by thestring in decimalString
formparameter. The string is converted toanalong
valueas ifin exactly the manner used by theint)parseLong
method for radix 10. @param s thestringString
to be converted to aLong
. @exception NumberFormatException if theString
does not contain a parsablelong
. @see java.lang.Long#valueOf(java.lang.String)integer
Constructs a newly allocatedClass Long, byte byteValue()Long
object that represents theprimitivespecifiedlong
argument. @param value the value to be represented by theLong
object.
Returns the value of thisClass Long, int compareTo(Long)Long
as abyte
.@since JDK1.1
Compares twoClass Long, int compareTo(Object)LongsLong
objects numerically. @param anotherLong theLong
to be compared. @return the value0
ifthe argumentthisLong
is equal tothisthe argumentLong; a value less than
0
if thisLong
is numerically less than theLongargumentLong
; and a value greater than0
if thisLong
is numerically greater than theLongargumentLong
(signed comparison). @since 1.2
Compares thisClass Long, Long decode(String)Long
object to anotherObjectobject. If theObjectobject is aLong
this function behaves likecompareTo(Long)
. Otherwise it throws aClassCastException
(asLongsLong
objects are comparable only to otherLongsLong
objects). @param o theObject
to be compared. @return the value0
if the argument is aLong
numerically equal to thisLong
; a value less than0
if the argument is aLong
numerically greater than thisLong
; and a value greater than0
if the argument is aLong
numerically less than thisLong
. @exceptionClassCastException
if the argument is not aLong
. @see java.lang.Comparable @since 1.2
Decodes aClass Long, double doubleValue()String
into aLong
. Accepts decimal hexadecimal and octal numbersingiven by the followingformatsgrammar:[-]DecimalNumeral HexDigits and OctalDigits are defined in §3.10.1 ofdecimal
constant- DecodableString:
[-]- Signopt DecimalNumeral
- Signopt
0x
hexHexDigits- Signopt
constant0X
[-]HexDigits- Signopt
#
HexDigits- Signopt
hex0
constantOctalDigits
- Sign:
[-
] 0octalconstantthe Java Language Specification.The
constantsequence of characters following an (optional) negative sign and/or"radix specifier"("0x
" "0X
" "#
" or leading zero) is parsed as by theLong.parseLong
method with thespecifiedindicated radix (10816 or168). Thisconstantsequence of characters mustberepresent a positive value or a NumberFormatException willresultbe thrown. The result ismadenegatednegativeif first character of the specifiedString
is thenegativeminus sign. No whitespace characters are permitted in theString
. @param nm theString
to decode. @returntheaLong
represented byobject holding thespecifiedlong
string.value represented bynm
@exception NumberFormatException if theString
does not contain a parsablelong
. @see java.lang.Long#parseLong(String int) @since 1.2
Returns the value of thisClass Long, boolean equals(Object)Long
as adouble. @return the long value represented by this object that is converted to typedouble
and the result of the conversion is returned.
Compares this objectClass Long, float floatValue()againstto the specified object. The result istrue
if and only if the argument is notnull
and is aLong
object that contains the samelong
value as this object. @param obj the object to compare with. @returntrue
if the objects are the same;false
otherwise.
Returns the value of thisClass Long, Long getLong(String)Long
as afloat. @return the long value represented by this object is converted to typefloat
and the result of the conversion is returned.
Determines theClass Long, Long getLong(String, Long)long
value of the system property with the specified name.The first argument is treated as the name of a system property. System properties are accessible through the java.lang.System#getProperty(java.lang.String) method. The string value of this property is then interpreted as a
long
value and aLong
object representing this value is returned. Details of possible numeric formats can be found with the definition ofgetProperty
.If there is no property with the specified name if the specified name is empty or
null
or if the property does not have the correct numeric format thennull
is returned.In other words this method returns a
Long
object equal to the value of:@param nm property name. @return thegetLong(nm null)
Long
value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String)
Returns theClass Long, Long getLong(String, long)long
value of the system property with the specified name. The first argument is treated as the name of a system property. System properties are accessible through the java.lang.System#getProperty(java.lang.String) method. The string value of this property is then interpreted as along
value as per theLong.decode
method and aLong
object representing this value is returned.
- If the property value begins with the two ASCII characters
0x
or the ASCII character#
not followed by a minus sign then the rest of it is parsed as a hexadecimal integer exactly as for the method int) with radix 16.- If the property value begins with the ASCII character
0
followed by another character it is parsed as an octal integer exactly asforby the method int) with radix 8.- Otherwise the property value is parsed as a decimal integer exactly as
forby the method int) with radix 10.Note that in every case neither
L
('\u004C'
) norl
('\u006C'
) is permitted to appear at the end of the property value as a type indicator as would be permitted in Java programming language source code.The second argument is the default value. The default value is returned if there is no property of the specified name if the property does not have the correct numeric format or if the specified name is empty or
null
. @param nm property name. @param val default value. @return theLong
value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String) @see java.lang.Long#decode
Determines theClass Long, int hashCode()long
value of the system property with the specified name.The first argument is treated as the name of a system property. System properties are accessible through the java.lang.System#getProperty(java.lang.String) method. The string value of this property is then interpreted as a
long
value and aLong
object representing this value is returned. Details of possible numeric formats can be found with the definition ofgetProperty
.The second argument is the default value. A
Long
object that represents the value of the second argument is returned if there is no property of the specified name if the property does not have the correct numeric format or if the specified name is empty or null.In other words this method returns a
Long
object equal to the value of:but in practice it may be implemented in a manner such as:getLong(nm new Long(val))
to avoid the unnecessary allocation of aLong result = getLong(nm null); return (result == null) new Long(val) : result;Long
object when the default value is not needed. @param nm property name. @param val default value. @return theLong
value of the property. @see java.lang.System#getProperty(java.lang.String) @see java.lang.System#getProperty(java.lang.String java.lang.String)
Class Long, int intValue()ComputesReturns ahashcodehash code for thisLong
. The result is the exclusive OR of the two halves of the primitivelong
valuerepresentedheld by thisLong
object. That is the hashcode is the value of the expression:@return a hash code value for this object.(int)(this.longValue()^(this.longValue()>>>32))
Returns the value of thisClass Long, long longValue()Long
as anint. @return the long value represented by this object is converted to typeint
and the result of the conversion is returned.
Returns the value of thisClass Long, long parseLong(String)Long
as along value. @return thelong
valuerepresented by this object.
Parses the string argument as a signed decimalClass Long, long parseLong(String, int)long
. The characters in the string must all be decimal digits except that the first character may be an ASCII minus sign'-'
(\
) to indicate a negative value. The resultingu002du002D'long
value is returned exactly as if the argument and the radix10
were given as arguments to the int) methodthat takes two arguments.Note that neither the character
L (
'\u004C'
) norl
('\u006C'
) is permitted to appear at the end of the string as a type indicator as would be permitted in Java programming language source code. @param s astring.String
containing thelong
representation to be parsed @return thelong
represented by the argument in decimal. @exception NumberFormatException if the string does not contain a parsablelong
.
Parses the string argument as a signedClass Long, short shortValue()long
in the radix specified by the second argument. The characters in the string must all be digits of the specified radix (as determined by whetherCharacter.digitint) returns a nonnegative value) except that the first character may be an ASCII minus sign'-'
('\
) to indicate a negative value. The resultingu002du002D'long
value is returned.Note that neither the character
L (
'\u004C'
) norl
('\u006C'
) is permitted to appear at the end of the string as a type indicator as would be permitted in Java programming language source code - except that eitherL
orl
may appear as a digit for a radix greater than 22.An exception of type
NumberFormatException
is thrown if any of the following situations occurs:
- The first argument is
null
or is a string of length zero.- The
radix
is either smaller than java.lang.Character#MIN_RADIX or larger than java.lang.Character#MAX_RADIXThe firstAny character of the string is not a digit of the specified radixand isexcept thatnotthe first character may be a minus sign'-'
('\u002d'
). The firstcharacter ofprovided that the string isa minus sign andlongerthe string is ofthan length 1.Any character of the string after the first is not a digit of the specified radix.Theintegervalue represented by the stringcannot be representedisasnot a value of typelong
.Examples:
@param s theparseLong("0" 10) returns 0L parseLong("473" 10) returns 473L parseLong("-0" 10) returns 0L parseLong("-FF" 16) returns -255L parseLong("1100110" 2) returns 102L parseLong("99" 8) throws a NumberFormatException parseLong("Hazelnut" 10) throws a NumberFormatException parseLong("Hazelnut" 36) returns 1356099454469LString
containing thelong
representation to be parsed. @param radix the radix to be used while parsings
. @return thelong
represented by the string argument in the specified radix. @exception NumberFormatException if the string does not contain a parsableintegerlong
.
Returns the value of thisClass Long, String toBinaryString(long)Long
as ashort
.@since JDK1.1
Class Long, String toHexString(long)CreatesReturns a string representation of thelong
argument as an unsigned integer in base 2.The unsigned
long
value is the argument plus 264 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in binary (base 2) with no extra leading0
s. If the unsigned magnitude is zero it is represented by a single zero character'0'
('&
); otherwise the first character of the representation of the unsigned magnitude will not be the zero character. The characters392#92;u0030''0'
('\u0030'
) and'1'
('\u0031'
) are used as binary digits. @param i along
to be converted to a string. @return the string representation of the unsignedlong
value represented by the argument in binary (base 2). @since JDK 1.0.2
Class Long, String toOctalString(long)CreatesReturns a string representation of thelong
argument as an unsigned integer in base 16.The unsigned
long
value is the argument plus 264 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with no extra leading0
s. If the unsigned magnitude is zero it is represented by a single zero character'0'
('\u0030'
); otherwise the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as hexadecimal digits:These are the characters0123456789abcdef'\u0030'
through'\u0039'
and'\u0061'
through'\u0066'
. If uppercase letters are desired the java.lang.String#toUpperCase() method may be called on the result:@param i aLong.toHexString(n).toUpperCase()long
to be converted to a string. @return the string representation of the unsignedlong
value represented by the argument in hexadecimal (base 16). @since JDK 1.0.2
Class Long, String toString()CreatesReturns a string representation of thelong
argument as an unsigned integer in base 8.The unsigned
long
value is the argument plus 264 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in octal (base 8) with no extra leading0
s.If the unsigned magnitude is zero it is represented by a single zero character
'0'
('\u0030'
); otherwise the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as octal digits:These are the characters01234567'\u0030'
through'\u0037'
. @param i along
to be converted to a string. @return the string representation of the unsignedlong
value represented by the argument in octal (base 8). @since JDK 1.0.2
Returns aClass Long, String toString(long)String
object representing thisLong
's value. Thelong integervaluerepresented by this Long objectis converted to signed decimal representation and returned as a string exactly as if thelong
value were given as an argument to the java.lang.Long#toString(long) methodthat takes one argument. @return a string representation of the value of this object in base 10.
Returns aClass Long, String toString(long, int)newString
object representing the specifiedintegerlong
. The argument is converted to signed decimal representation and returned as a string exactly as if the argument and the radix 10 were given as arguments to the int) methodthat takes two arguments. @param i along
to be converted. @return a string representation of the argument in base 10.
Class Long, Long valueOf(String)CreatesReturns a string representation of the first argument in the radix specified by the second argument.If the radix is smaller than
Character.MIN_RADIX
or larger thanCharacter.MAX_RADIX
then the radix10
is used instead.If the first argument is negative the first element of the result is the ASCII minus sign
'-'
('\u002d'
). If the first argument is not negative no sign character appears in the result.The remaining characters of the result represent the magnitude of the first argument. If the magnitude is zero it is represented by a single zero character
'0'
('\u0030'
); otherwise the first character of the representation of the magnitude will not be the zero character. The following ASCII characters are used as digits:These are0123456789abcdefghijklmnopqrstuvwxyz'\u0030'
through'\u0039'
and'\u0061'
through'\u007a'
. Iftheradix
is N then the first N of these characters are used as radix-N digits in the order shown. Thus the digits for hexadecimal (radix 16) are0123456789abcdef
. If uppercase letters are desired the java.lang.String#toUpperCase() method may be called on the result:@param i aLong.toString(n 16).toUpperCase()long
to be converted to a string. @param radix the radix to use in the string representation. @return a string representation of the argument in the specified radix. @see java.lang.Character#MAX_RADIX @see java.lang.Character#MIN_RADIX
Returns aClass Long, Long valueOf(String, int)new longLong
objectinitialized toholding the value of the specifiedString. Throws an exception if theString
.cannot be parsed as a long. The radix is assumed to be 10The argument is interpreted as representing a signed decimalintegerlong
exactly as if the argument were given to the #parseLong(java.lang.String) methodthat takes one argument). The result is aLong
object that represents the integer value specified by the string.In other words this method returns a
Long
object equal to the value of:@param s the string to be parsed. @return anew Long(Long.parseLong(s))newly constructedLong
initialized toobject holding the value represented by the string argument. @exception NumberFormatException If theStringstring cannotdoes not containbe parsed as aparsablelong
.
Returns aClass Long, long MAX_VALUEnew longLong
objectinitialized toholding the valueofextracted from the specifiedString
. Throwsan exception ifwhen parsed with theString cannotradixbe parsed as a longgiven by the second argument.The first argument is interpreted as representing a signedintegerlong
in the radix specified by the second argument exactly as if the arguments were given to the int) methodthat takes two arguments. The result is aLong
object that represents theintegerlong
value specified by the string.In other words this method returns a
Long
object equal to the value of:@param s thenew Long(Long.parseLong(s radix))
Stringstringcontaining theto belong.parsed @param radix the radix to be used.in interpretings
@return anewly constructedLong
initialized toobject holding the value represented by the string argument in the specified radix. @exception NumberFormatException If theString
does not contain a parsablelong
.
Class Long, long MIN_VALUEThe largestA constantvalueholding theofmaximum valuetypealong
can have 263-1.
Class Long, Class TYPEThe smallestA constantvalueholding theofminimum valuetypealong
can have -263.
TheClass
objectinstance representing the primitive typelong
. @since JDK1.1
The classClass Math, double abs(double)Math
contains methods for performing basic numeric operations such as the elementary exponential logarithm square root and trigonometric functions.Unlike some of the numeric
functionsmethods of classStrictMath
all implementations of the equivalent functions of classMath
are not defined to return the bit-for-bit same results. This relaxation permits better-performing implementations where strict reproducibility is not required.By default many of the
Math
functionsmethods simplydelegatecalltothe equivalentfunctionsmethod inStrictMath
for theirimplementationsimplementation. Code generators are encouraged to use platform-specific native libraries or microprocessor instructions where available to provide higher-performance implementations ofMath
functionsmethods. Such higher-performance implementations still must conform to the specification forMath
.The quality of implementation specifications concern two properties accuracy of the returned result and monotonicity of the method. Accuracy of the floating-point
Math
methods is measured in terms of ulps units in the last place. For a given floating-point format an ulp of a specific real number value is the difference between the two floating-point values closest to that numerical value. When discussing the accuracy of a method as a whole rather than at a specific argument the number of ulps cited is for the worst-case error at any argument. If a method always has an error less than 0.5 ulps the method always returns the floating-point number nearest the exact result; such a method is correctly rounded. A correctly rounded method is generally the best a floating-point approximation can be; however it is impractical for many floating-point methods to be correctly rounded. Instead for theMath
class a larger error bound of 1 or 2 ulps is allowed for certain methods. Informally with a 1 ulp error bound when the exact result is a representable number the exact result should be returned; otherwise either of the two floating-point numbers closest to the exact result may be returned. Besides accuracy at individual arguments maintaining proper relations between the method at different arguments is also important. Therefore methods with more than 0.5 ulp errors are required to be semi-monotonic: whenever the mathematical function is non-decreasing so is the floating-point approximation likewise whenever the mathematical function is non-increasing so is the floating-point approximation. Not all approximations that have 1 ulp accuracy will automatically meet the monotonicity requirements. @author unascribed @version 1.50 0254 12/0203/0001 @since JDK1.0
Returns the absolute value of aClass Math, float abs(float)double
value. If the argument is not negative the argument is returned. If the argument is negative the negation of the argument is returned. Special cases:In other words the result is
- If the argument is positive zero or negative zero the result is positive zero.
- If the argument is infinite the result is positive infinity.
- If the argument is NaN the result is NaN.
equalthetosame as the value of the expression:
Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)
@param aathedoubleargument whose absolute value.is to be determined @return the absolute value of the argument.
Returns the absolute value of aClass Math, int abs(int)float
value. If the argument is not negative the argument is returned. If the argument is negative the negation of the argument is returned. Special cases:In other words the result is
- If the argument is positive zero or negative zero the result is positive zero.
- If the argument is infinite the result is positive infinity.
- If the argument is NaN the result is NaN.
equalthetosame as the value of the expression:Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))@param aathefloatargument whose absolute value.is to be determined @return the absolute value of the argument.
Returns the absolute value of anClass Math, long abs(long)int
value. If the argument is not negative the argument is returned. If the argument is negative the negation of the argument is returned.Note that if the argument is equal to the value of
Integer.MIN_VALUE
the most negative representableint
value the result is that same value which is negative. @param aantheintargument whose absolute value.is to be determined @return the absolute value of the argument. @see java.lang.Integer#MIN_VALUE
Returns the absolute value of aClass Math, double acos(double)long
value. If the argument is not negative the argument is returned. If the argument is negative the negation of the argument is returned.Note that if the argument is equal to the value of
Long.MIN_VALUE
the most negative representablelong
value the result is that same value which is negative. @param aathelongargument whose absolute value.is to be determined @return the absolute value of the argument. @see java.lang.Long#MIN_VALUE
Returns the arc cosine of an angle in the range of 0.0 through pi. Special case:Class Math, double asin(double)
- If the argument is NaN or its absolute value is greater than 1 then the result is NaN.
A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a the
doublevalue whose arc cosine is to be returned. @return the arc cosine of the argument.
Returns the arc sine of an angle in the range of -pi/2 through pi/2. Special cases:Class Math, double atan(double)
- If the argument is NaN or its absolute value is greater than 1 then the result is NaN.
- If the argument is
positivezero then the result ispositivea zero;ifwith theargument is negativesamezero thensign as theresult is negative zeroargument.A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a the
doublevalue whose arc sine is to be returned. @return the arc sine of the argument.
Returns the arc tangent of an angle in the range of -pi/2 through pi/2. Special cases:Class Math, double atan2(double, double)
- If the argument is NaN then the result is NaN.
- If the argument is
positivezero then the result ispositivea zero;ifwith theargument is negativesamezero thensign as theresult is negative zeroargument.A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a the
doublevalue whose arc tangent is to be returned. @return the arc tangent of the argument.
Converts rectangular coordinates (Class Math, double ceil(double)
bx) to polar (r theta). This method computes the phase theta by computing an arc tangent of
ayin the range of -pi to pi. Special cases:
ay/bx
- If either argument is NaN then the result is NaN.
- If the first argument is positive zero and the second argument is positive or the first argument is positive and finite and the second argument is positive infinity then the result is positive zero.
- If the first argument is negative zero and the second argument is positive or the first argument is negative and finite and the second argument is positive infinity then the result is negative zero.
- If the first argument is positive zero and the second argument is negative or the first argument is positive and finite and the second argument is negative infinity then the result is the
double
value closest to pi.- If the first argument is negative zero and the second argument is negative or the first argument is negative and finite and the second argument is negative infinity then the result is the
double
value closest to -pi.- If the first argument is positive and the second argument is positive zero or negative zero or the first argument is positive infinity and the second argument is finite then the result is the
double
value closest to pi/2.- If the first argument is negative and the second argument is positive zero or negative zero or the first argument is negative infinity and the second argument is finite then the result is the
double
value closest to -pi/2.- If both arguments are positive infinity then the result is the
double
value closest to pi/4.- If the first argument is positive infinity and the second argument is negative infinity then the result is the
double
value closest to 3*pi/4.- If the first argument is negative infinity and the second argument is positive infinity then the result is the
double
value closest to -pi/4.- If both arguments are negative infinity then the result is the
double
value closest to -3*pi/4.A result must be within 2 ulps of the correctly rounded result. Results must be semi-monotonic. @param
a ay thedoubleordinatevalue.coordinate @paramb ax thedoubleabscissavalue.coordinate @return the theta component of the point (r theta) in polar coordinates that corresponds to the point (bxay) in Cartesian coordinates.
Returns the smallest (closest to negative infinity)Class Math, double cos(double)double
value that is not less than the argument and is equal to a mathematical integer. Special cases:Note that the value of
- If the argument value is already equal to a mathematical integer then the result is the same as the argument.
- If the argument is NaN or an infinity or positive zero or negative zero then the result is the same as the argument.
- If the argument value is less than zero but greater than -1.0 then the result is negative zero.
Math.ceil(x)
is exactly the value of-Math.floor(-x)
. @param a adoublevalue. <--@return the value ⌈a
⌉.--> @return the smallest (closest to negative infinity)doublefloating-point value that is not less than the argument and is equal to a mathematical integer.
Returns the trigonometric cosine of an angle. SpecialClass Math, double exp(double)casecases:
- If the argument is NaN or an infinity then the result is NaN.
A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a an angle in radians. @return the cosine of the argument.
ReturnsClass Math, double floor(double)the exponentialEuler's number e(i.e. 2.718...)raised to the power of adouble
value. Special cases:
- If the argument is NaN the result is NaN.
- If the argument is positive infinity then the result is positive infinity.
- If the argument is negative infinity then the result is positive zero.
A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a
athedoubleexponentvalueto raise e to. @return the value ea
where e is the base of the natural logarithms.
Returns the largest (closest to positive infinity)Class Math, double max(double, double)double
value that is not greater than the argument and is equal to a mathematical integer. Special cases:@param a a
- If the argument value is already equal to a mathematical integer then the result is the same as the argument.
- If the argument is NaN or an infinity or positive zero or negative zero then the result is the same as the argument.
doublevalue. <--@return the value ⌊a
⌋.--> @return the largest (closest to positive infinity)doublefloating-point value that is not greater than the argument and is equal to a mathematical integer.
Returns the greater of twoClass Math, float max(float, float)double
values. That is the result is the argument closer to positive infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero the result is positive zero. @param aa doubleanvalueargument. @param ba doubleanothervalueargument. @return the larger ofa
andb
.
Returns the greater of twoClass Math, int max(int, int)float
values. That is the result is the argument closer to positive infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero the result is positive zero. @param aa floatanvalueargument. @param ba floatanothervalueargument. @return the larger ofa
andb
.
Returns the greater of twoClass Math, long max(long, long)int
values. That is the result is the argument closer to the value ofInteger.MAX_VALUE
. If the arguments have the same value the result is that same value. @param a anint valueargument. @param ban intanothervalueargument. @return the larger ofa
andb
. @see java.lang.Long#MAX_VALUE
Returns the greater of twoClass Math, double min(double, double)long
values. That is the result is the argument closer to the value ofLong.MAX_VALUE
. If the argumens have the same value the result is that same value. @param aa longanvalueargument. @param ba longanothervalueargument. @return the larger ofa
andb
. @see java.lang.Long#MAX_VALUE
Returns the smaller of twoClass Math, float min(float, float)double
values. That is the result is the value closer to negative infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero the result is negative zero. @param aa doubleanvalueargument. @param ba doubleanothervalueargument. @return the smaller ofa
andb
.
Returns the smaller of twoClass Math, int min(int, int)float
values. That is the result is the value closer to negative infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero the result is negative zero. @param aa floatanvalueargument. @param ba floatanothervalueargument. @return the smaller ofa
andb.
Returns the smaller of twoClass Math, long min(long, long)int
values. That is the result the argument closer to the value ofInteger.MIN_VALUE
. If the arguments have the same value the result is that same value. @param a anint valueargument. @param ban intanothervalueargument. @return the smaller ofa
andb
. @see java.lang.Long#MIN_VALUE
Returns the smaller of twoClass Math, double pow(double, double)long
values. That is the result is the argument closer to the value ofLong.MIN_VALUE
. If the arguments have the same value the result is that same value. @param aa longanvalueargument. @param ba longanothervalueargument. @return the smaller ofa
andb
. @see java.lang.Long#MIN_VALUE
Returns of value of the first argument raised to the power of the second argument. Special cases:Class Math, double rint(double)
- If the second argument is positive or negative zero then the result is 1.0.
- If the second argument is 1.0 then the result is the same as the first argument.
- If the second argument is NaN then the result is NaN.
- If the first argument is NaN and the second argument is nonzero then the result is NaN.
- If the absolute value of the first argument is greater than 1 and the second argument is positive infinity or the absolute value of the first argument is less than 1 and the second argument is negative infinity then the result is positive infinity.
- If the absolute value of the first argument is greater than 1 and the second argument is negative infinity or the absolute value of the first argument is less than 1 and the second argument is positive infinity then the result is positive zero.
- If the absolute value of the first argument equals 1 and the second argument is infinite then the result is NaN.
- If the first argument is positive zero and the second argument is greater than zero or the first argument is positive infinity and the second argument is less than zero then the result is positive zero.
- If the first argument is positive zero and the second argument is less than zero or the first argument is positive infinity and the second argument is greater than zero then the result is positive infinity.
- If the first argument is negative zero and the second argument is greater than zero but not a finite odd integer or the first argument is negative infinity and the second argument is less than zero but not a finite odd integer then the result is positive zero.
- If the first argument is negative zero and the second argument is a positive finite odd integer or the first argument is negative infinity and the second argument is a negative finite odd integer then the result is negative zero.
- If the first argument is negative zero and the second argument is less than zero but not a finite odd integer or the first argument is negative infinity and the second argument is greater than zero but not a finite odd integer then the result is positive infinity.
- If the first argument is negative zero and the second argument is a negative finite odd integer or the first argument is negative infinity and the second argument is a positive finite odd integer then the result is negative infinity.
- If the first argument is less than zero and the second argument is a finite even integer then the result is equal to the result of raising the absolute value of the first argument to the power of the second argument.
- If the first argument is less than zero and the second argument is a finite odd integer then the result is equal to the negative of the result of raising the absolute value of the first argument to the power of the second argument.
- If the first argument is finite and less than zero and the second argument is finite and not an integer then the result is NaN.
- If both arguments are integers then the result is exactly equal to the mathematical result of raising the first argument to the power of the second argument if that result can in fact be represented exactly as a double value.
(In the foregoing descriptions a floating-point value is considered to be an integer if and only if it is a fixed point of the method ceil or
whichequivalentlyis the same thinga fixed point of the method floor A value is a fixed point of a one-argument method if and only if the result of applying the method to the value is equal to the value.)A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a
a doublethevaluebase. @param ba doublethevalueexponent. @return the valueab
.
Returns theClass Math, long round(double)double
value that is closest in value toathe argument and is equal to a mathematical integer. If twodouble
values that are mathematical integers are equally closeto the value of the argumentthe result is the integer value that is even. Special cases:@param a a
- If the argument value is already equal to a mathematical integer then the result is the same as the argument.
- If the argument is NaN or an infinity or positive zero or negative zero then the result is the same as the argument.
double
value. @return the closestdoublefloating-point value toa
that is equal to a mathematical integer.
Returns the closestClass Math, int round(float)long
to the argument. The result is rounded to an integer by adding 1/2 taking the floor of the result and casting the result to typelong
. In other words the result is equal to the value of the expression:(long)Math.floor(a + 0.5d)Special cases:
@param a a
- If the argument is NaN the result is 0.
- If the argument is negative infinity or any value less than or equal to the value of
Long.MIN_VALUE
the result is equal to the value ofLong.MIN_VALUE
.- If the argument is positive infinity or any value greater than or equal to the value of
Long.MAX_VALUE
the result is equal to the value ofLong.MAX_VALUE
.doublefloating-point value to be rounded to along
. @return the value of the argument rounded to the nearestlong
value. @see java.lang.Long#MAX_VALUE @see java.lang.Long#MIN_VALUE
Returns the closestClass Math, double sin(double)int
to the argument. The result is rounded to an integer by adding 1/2 taking the floor of the result and casting the result to typeint
. In other words the result is equal to the value of the expression:(int)Math.floor(a + 0.5f)Special cases:
@param a a
- If the argument is NaN the result is 0.
- If the argument is negative infinity or any value less than or equal to the value of
Integer.MIN_VALUE
the result is equal to the value ofInteger.MIN_VALUE
.- If the argument is positive infinity or any value greater than or equal to the value of
Integer.MAX_VALUE
the result is equal to the value ofInteger.MAX_VALUE
.floatfloating-point value to be rounded to an integer. @return the value of the argument rounded to the nearestint
value. @see java.lang.Integer#MAX_VALUE @see java.lang.Integer#MIN_VALUE
Returns the trigonometric sine of an angle. Special cases:Class Math, double sqrt(double)
- If the argument is NaN or an infinity then the result is NaN.
- If the argument is
positivezero then the result ispositivea zero;ifwith theargument is negativesamezero thensign as theresult is negative zeroargument.A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a an angle in radians. @return the sine of the argument.
Returns the correctly rounded positive square root of aClass Math, double tan(double)double
value. Special cases:Otherwise the result is the
- If the argument is NaN or less than zero then the result is NaN.
- If the argument is positive infinity then the result is positive infinity.
- If the argument is positive zero or negative zero then the result is the same as the argument.
double
value closest to the true mathetmatical square root of the argument value. @param a adoublevalue. <--@return the value of √a
.--> @return the positive square root ofa
. If the argument is NaN or less than zero the result is NaN.
Returns the trigonometric tangent of an angle. Special cases:Class Math, double toDegrees(double)
- If the argument is NaN or an infinity then the result is NaN.
- If the argument is
positivezero then the result ispositivea zero;ifwith theargument is negativesamezero thensign as theresult is negative zeroargument.A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic. @param a an angle in radians. @return the tangent of the argument.
Converts an angle measured in radians toClass Math, double toRadians(double)thean approximately equivalent angle measured in degrees. The conversion from radians to degrees is generally inexact; users should not expectcos(toRadians(90.0))
to exactly equal0.0
. @param angrad an angle in radians @return the measurement of the angleangrad
in degrees. @since 1.2
Converts an angle measured in degrees toClass Math, double Ethean approximately equivalent angle measured in radians. The conversion from degrees to radians is generally inexact. @param angdeg an angle in degrees @return the measurement of the angleangdeg
in radians. @since 1.2
The double
value that is closer than any other to e the base of the natural logarithms.
Thrown if an application tries to create an array with negative size. @author unascribed @version 1.16 0217 12/0203/0001 @since JDK1.0
Thrown if the Java Virtual Machine or aclassloaderClassLoader
instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using thenew
expression) and no definition of the class could be found.The searched-for class definition existed when the currently executing class was compiled but the definition can no longer be found. @author unascribed @version 1.
17 0220 12/0203/0001 @since JDK1.0
Thrown if an application tries to access or modify a specified field of an object and that object no longer has that field.Normally this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. @author unascribed @version 1.
9 0210 12/0203/0001 @since JDK1.0
Signals that the class doesn't have a field of a specified name. @author unascribed @version 1.11 0212 12/0203/0001 @since JDK1.1
Thrown if an application tries to call a specified method of a class (either static or instance) and that class no longer has a definition of that method.Normally this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. @author unascribed @version 1.
18 0219 12/0203/0001 @since JDK1.0
Thrown when a particular method cannot be found. @author unascribed @version 1.10 0211 12/0203/0001 @since JDK1.0
Thrown when an application attempts to usenull
in a case where an object is required. These include:
- Calling the instance method of a
null
object.- Accessing or modifying the field of a
null
object.- Taking the length of
null
as if it were an array.- Accessing or modifying the slots of
null
as if it were an array.- Throwing
null
as if it were aThrowable
value.Applications should throw instances of this class to indicate other illegal uses of the
null
object. @author unascribed @version 1.16 0217 12/0203/0001 @since JDK1.0
The abstract classClass Number, int intValue()Number
is the superclass of classesBigDecimal
BigInteger
Byte
Double
Float
Integer
Long
andShort
.Subclasses of
Number
must provide methods to convert the represented numeric value tobyte
double
float
int
long
andshort
. @author Lee Boynton @author Arthur van Hoff @version 1.25 0227 12/0203/0001 @see java.lang.Byte @see java.lang.Double @see java.lang.Float @see java.lang.Integer @see java.lang.Long @see java.lang.Short @since JDK1.0
Returns the value of the specified number as anClass Number, long longValue()int
. This may involve rounding or truncation. @return the numeric value represented by this object after conversion to typeint
.
Returns the value of the specified number as along
. This may involve rounding or truncation. @return the numeric value represented by this object after conversion to typelong
.
Thrown to indicate that the application has attempted to convert a string to one of the numeric types but that the string does not have the appropriate format. @author unascribed @version 1.16 0217 12/0203/0001 @see java.lang.Integer#toString() @since JDK1.0
ClassClass Object, Object clone()Object
is the root of the class hierarchy. Every class hasObject
as a superclass. All objects including arrays implement the methods of this class. @author unascribed @version 1.54 0258 12/0203/0001 @see java.lang.Class @since JDK1.0
Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that for any object x the expression:Class Object, boolean equals(Object)will be true and that the expression:x.clone() = xwill be true but these are not absolute requirements. While it is typically the case that:x.clone().getClass() == x.getClass()will be true this is not an absolute requirement.x.clone().equals(x)Copying
anBy convention the returned objectwillshouldtypicallybe obtained by callingentailsuper.clone.creatingIf anewclassinstanceand all of itsclasssuperclassesbut(except Object) obey this convention italsowill be the case that x.clone().getClass() == x.getClass().By convention the object returned by this method should
be independent of this object (which is being cloned). To achieve this independence it mayrequirebecopyingnecessary to modify one or more fields of the object returned by super.clone before returning it. Typically this means copying any mutable objects that comprise the internaldata"deep structure"structuresofasthe object being cloned and replacing thewellreferences to these objects with references to the copies.NoIf aconstructorsclassarecontains only primitive fields or references to immutable objects then it is usually the case that no fieldscalledin the object returned by super.clone need to be modified.The method clone for class Object performs a specific cloning operation. First if the class of this object does not implement the interface Cloneable then a CloneNotSupportedException is thrown. Note that all arrays are considered to implement the interface Cloneable. Otherwise this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object as if by assignment; the contents of the fields are not themselves cloned. Thus this method performs a "shallow copy" of this object not a "deep copy" operation.
The class Object does not itself implement the interface Cloneable so calling the clone method on an object whose class is Object will result in throwing an exception at run time.
The clone method is implemented by the class Object as a convenient general utility for subclasses that implement the interface Cloneable possibly also overriding the clone method in which case the overriding definition can refer to this utility definition by the call: super.clone()@return a clone of this instance. @exception CloneNotSupportedException if the object's class does not support theCloneable
interface. Subclasses that override theclone
method can also throw this exception to indicate that an instance cannot be cloned. @exception OutOfMemoryError if there is not enough memory. @see java.lang.Cloneable
Indicates whether some other object is "equal to" this one.Class Object, void wait()The
equals
method implements an equivalence relation:
- It is reflexive: for any reference value
x
x.equals(x)
should returntrue
.- It is symmetric: for any reference values
x
andy
x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
.- It is transitive: for any reference values
x
y
andz
ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
thenx.equals(z)
should returntrue
.- It is consistent: for any reference values
x
andy
multiple invocations of x.equals(y) consistently returntrue
or consistently returnfalse
provided no information used inequals
comparisons on the object is modified.- For any non-null reference value
x
x.equals(null)
should returnfalse
.The equals method for class
Object
implements the most discriminating possible equivalence relation on objects; that is for any reference valuesx
andy
this method returnstrue
if and only ifx
andy
refer to the same object (x==y
has the valuetrue
).Note that it is generally necessary to override the hashCode method whenever this method is overridden so as to maintain the general contract for the hashCode method which states that equal objects must have equal hash codes. @param obj the reference object with which to compare. @return
true
if this object is the same as the obj argument;false
otherwise. @seejava.lang.Boolean#hashCode() @see java.util.Hashtable
Causes current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object. In otherword'swords this method behaves exactly as if it simply performs the call wait(0).The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the
notify
method or thenotifyAll
method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a description of the ways in which a thread can become the owner of a monitor. @exception IllegalMonitorStateException if the current thread is not the owner of the object's monitor. @exception InterruptedException if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown. @see java.lang.Object#notify() @see java.lang.Object#notifyAll()
Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory and no more memory could be made available by the garbage collector. @author unascribed @version 1.18 0219 12/0203/0001 @since JDK1.0
Class Package, Package getPackage(String)Package
objects contain version information about the implementation and specification of a Java package. This versioning information is retrieved and made available by theclassloaderClassLoader
instance that loaded the class(es). Typically it is stored in the manifest that is distributed with the classes.The set of classes that make up the package may implement a particular specification and if so the specification title version number and vendor strings identify that specification. An application can ask if the package is compatible with a particular version see the
isCompatibleWith
method for details.Specification version numbers use a "Dewey Decimal" syntax that consists of positive decimal integers separated by periods "." for example "2.0" or "1.2.3.4.5.6.7". This allows an extensible number to be used to represent major minor micro etc versions. The version number must begin with a number.
The implementation title version and vendor strings identify an implementation and are made available conveniently to enable accurate reporting of the packages involved when a problem occurs. The contents all three implementation strings are vendor specific. The implementation version strings have no specified syntax and should only be compared for equality with desired version identifers. Within each
classloaderClassLoader
instance all classes from the same java package have the same Package object. The static methods allow a package to be found by name or the set of all packages known to the current class loader to be found.@see ClassLoader#definePackage
Find a package by name in the callersClass Package, Package[] getPackages()classloaderClassLoader
instance. The callersclassloaderClassLoader
instance is used to find the package instance corresponding to the named class. If the callersclassloaderClassLoader
instance is null then the set of packages loaded by the systemclassloaderClassLoader
instance is searched to find the named package.Packages have attributes for versions and specifications only if the class loader created the package instance with the appropriate attributes. Typically those attributes are defined in the manifests that accompany the classes. @param name a package name for example java.lang. @return the package of the requested name. It may be null if no package information is available from the archive or codebase.
Get all the packages currently known for the caller'sClass Package, int hashCode()classClassLoader
loaderinstance. Those packages correspond to classes loaded via or accessible by name to thatclassClassLoader
loaderinstance. If the caller'sclassClassLoader
loaderinstance is the bootstrapclassloaderClassLoader
instance which may be represented bynull
in some implementations only packages corresponding to classes loaded by the bootstrapclassClassLoader
loaderinstance will be returned. @return a new array of packages known to the callersclassloaderClassLoader
instance. An zero length array is returned if none are known.
Return thehashcodehash code computed from the package name. @return thehodecodehode code computed from the package name.
TheRuntime.exec
methods create a native process and return an instance of a subclass ofProcess
that can be used to control the process and obtain information about it. The classProcess
provides methods for performing input from the process performing output to the process waiting for the process to complete checking the exit status of the process and destroying (killing) the process.The
Runtime.exec
methods may not work well for special processes on certain native platforms such as native windowing processes daemon processes Win16/DOS processes on Win32 or shell scripts. The created subprocess does not have its own terminal or console. All its standard io (i.e. stdin stdout stderr) operations will be redirected to the parent process through three streams (Process.getOutputStream()
Process.getInputStream()
Process.getErrorStream()
). The parent process uses these streams to feed input to and get output from the subprocess. Because some native platforms only provide limited buffer size for standard input and output streams failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block and even deadlock.The subprocess is not killed when there are no more references to the
Process
object but rather the subprocess continues executing asynchronously.There is no requirement that a process represented by a
Process
object execute asynchronously or concurrently with respect to the Java process that owns theProcess
object. @author unascribed @version 1.17 0218 12/0203/0001 @see java.lang.Runtime#exec(java.lang.String) @see java.lang.Runtime#exec(java.lang.String java.lang.String[]) @see java.lang.Runtime#exec(java.lang.String[]) @see java.lang.Runtime#exec(java.lang.String[] java.lang.String[]) @since JDK1.0
TheRunnable
interface should be implemented by any class whose instances are intended to be executed by a thread. The class must define a method of no arguments calledrun
.This interface is designed to provide a common protocol for objects that wish to execute code while they are active. For example
Runnable
is implemented by classThread
. Being active simply means that a thread has been started and has not yet been stopped.In addition
Runnable
provides the means for a class to be active while not subclassingThread
. A class that implementsRunnable
can run without subclassingThread
by instantiating aThread
instance and passing itself in as the target. In most cases theRunnable
interface should be used if you are only planning to override therun()
method and no otherThread
methods. This is important because classes should not be subclassed unless the programmer intends on modifying or enhancing the fundamental behavior of the class. @author Arthur van Hoff @version 1.21 0222 12/0203/0001 @see java.lang.Thread @since JDK1.0
Every Java application has a single instance of classClass Runtime, Process exec(String, String[], File)Runtime
that allows the application to interface with the environment in which the application is running. The current runtime can be obtained from thegetRuntime
method.An application cannot create its own instance of this class. @author unascribed @version 1.
57 0462 12/0603/0001 @see java.lang.Runtime#getRuntime() @since JDK1.0
Executes the specified string command in a separate process with the specified environment and working directory.Class Runtime, Process exec(String[], String[], File)This method breaks the
command
string into tokens and creates a new arraycmdarray
containing the tokens in the order that they were produced by the string tokenizer; it then performs the callexec(cmdarray envp)
. The token parsing is done by a java.util.StringTokenizer created by the call:with no further modification of the character categories.new StringTokenizer(command)The environment variable settings are specified by envp. If envp is null the subprocess inherits the environment settings of the current process.
The working directory of the new subprocess is specified by dir. If dir is null the subprocess inherits the current working directory of the current process. @param command a specified system command. @param envp array of strings each element of which has environment variable settings in format name=value. @param dir the working directory of the subprocess or null if the subprocess should inherit the working directory of the current process. @return a
Process
object for managing the subprocess. @exception SecurityException if a security manager exists and itscheckExec
method doesn't allow creation of a subprocess. @exception IOException if an I/O error occurs @see java.lang.Runtime#exec(java.lang.String[] java.lang.String[] File) @see java.lang.SecurityManager#checkExec(java.lang.String) @since 1.3
Executes the specified command and arguments in a separate process with the specified environment and working directory.Class Runtime, long freeMemory()If there is a security manager its
checkExec
method is called with the first component of the arraycmdarray
as its argument. This may result in a security exception.Given an array of strings
cmdarray
representing the tokens of a command line and an array of stringsenvp
representing "environment" variable settings this method creates a new process in which to execute the specified command.If envp is null the subprocess inherits the environment settings of the current process.
The working directory of the new subprocess is specified by dir. If dir is null the subprocess inherits the current working directory of the current process. @param cmdarray array containing the command to call and its arguments. @param envp array of strings each element of which has environment variable settings in format name=value. @param dir the working directory of the subprocess or null if the subprocess should inherit the working directory of the current process. @return a
Process
object for managing the subprocess. @exception SecurityException if a security manager exists and itscheckExec
method doesn't allow creation of a subprocess. @exception NullPointerException ifcmdarray
isnull
. @exception IndexOutOfBoundsException ifcmdarray
is an empty array (has length0
). @exception IOException if an I/O error occurs. @see java.lang.Process @see java.lang.SecurityException @see java.lang.SecurityManager#checkExec(java.lang.String) @since 1.3
Returns the amount of free memory in theClass Runtime, void gc()systemJava Virtual Machine. Calling thegc
method may result in increasing the value returned byfreeMemory.
@return an approximation to the total amount of memory currently available for future allocated objects measured in bytes.
Runs the garbage collector. Calling this method suggests that the JavaClass Runtime, InputStream getLocalizedInputStream(InputStream)Virtual Machinevirtual machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call theJava VirtualvirtualMachinemachine has made its best effort to recycle all discarded objects.The name
gc
stands for "garbage collector". TheJava VirtualvirtualMachinemachine performs this recycling process automatically as needed in a separate thread even if thegc
method is not invoked explicitly.The method System#gc() is
htethe conventional and convenient means of invoking this method.
Creates a localized version of an input stream. This method takes anClass Runtime, void load(String)InputStream
and returns anInputStream
equivalent to the argument in all respects except that it is localized: as characters in the local character set are read from the stream they are automatically converted from the local character set to Unicode.If the argument is already a localized stream it may be returned as the result. @param in InputStream to localize @return a localized input stream @see java.io.InputStream @see java.io.BufferedReader#BufferedReader(java.io.Reader) @see java.io.InputStreamReader#InputStreamReader(java.io.InputStream) @deprecated As of JDK 1.1 the preferred way to translate a byte stream in the local encoding into a character stream in Unicode is via the
InputStreamReader
andBufferedReader
classes.
Loads the specified filename as a dynamic library. The filename argument must be a completeClass Runtime, void runFinalization()pathnamepath name. Fromjava_g
it will automagically insert "_g" before the ".so" (for exampleRuntime.getRuntime().load("/home/avh/lib/libX11.so");
).First if there is a security manager its
checkLink
method is called with thefilename
as its argument. This may result in a security exception.This is similar to the method #loadLibrary(String) but it accepts a general file name as an argument
rathanrather than just a library name allowing any file of native code to be loaded.The method System#load(String) is the conventional and convenient means of invoking this method. @param filename the file to load. @exception SecurityException if a security manager exists and its
checkLink
method doesn't allow loading of the specified dynamic library @exception UnsatisfiedLinkError if the file does not exist. @see java.lang.Runtime#getRuntime() @see java.lang.SecurityException @see java.lang.SecurityManager#checkLink(java.lang.String)
Runs the finalization methods of any objects pending finalization. Calling this method suggests that the JavaClass Runtime, long totalMemory()Virtual Machinevirtual machine expend effort toward running thefinalize
methods of objects that have been found to be discarded but whosefinalize
methods have not yet been run. When control returns from the method call theJava VirtualvirtualMachinemachine has made a best effort to complete all outstanding finalizations.The
Java VirtualvirtualMachinemachine performs the finalization process automatically as needed in a separate thread if therunFinalization
method is not invoked explicitly.The method System#runFinalization() is the conventional and convenient means of invoking this method. @see java.lang.Object#finalize()
Returns the total amount of memory in the JavaClass Runtime, void traceInstructions(boolean)Virtual Machinevirtual machine. The value returned by this method may vary over time depending on the host environment.Note that the amount of memory required to hold an object of any given type may be implementation-dependent. @return the total amount of memory currently available for current and future objects measured in bytes.
Enables/Disables tracing of instructions. If theClass Runtime, void traceMethodCalls(boolean)boolean
argument istrue
this method suggests that the JavaVirtual Machinevirtual machine emit debugging information for each instruction in theJava VirtualvirtualMachinemachine as it is executed. The format of this information and the file or other output stream to which it is emitted depends on the host environment. The virtual machine may ignore this request if it does not support this feature. The destination of the trace output is system dependent.If the
boolean
argument isfalse
this method causes theJava VirtualvirtualMachinemachine to stop performing the detailed instruction trace it is performing. @param ontrue
to enable instruction tracing;false
to disable this feature.
Enables/Disables tracing of method calls. If theboolean
argument istrue
this method suggests that the JavaVirtual Machinevirtual machine emit debugging information for each method in theJava VirtualvirtualMachinemachine as it is called. The format of this information and the file or other output stream to which it is emitted depends on the host environment. The virtual machine may ignore this request if it does not support this feature.Calling this method with argument false suggests that the
Java VirtualvirtualMachinemachine cease emitting per-call debugging information. @param ontrue
to enable instruction tracing;false
to disable this feature.
Class RuntimeException, constructor RuntimeException()RuntimeException
is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine.A method is not required to declare in its
throws
clause any subclasses ofRuntimeException
that might be thrown during the execution of the method but not caught. @author Frank Yellin @version 1.9 0211 12/0203/0001 @since JDK1.0
Constructs a new runtime exception withClass RuntimeException, constructor RuntimeException(String)
RuntimeExceptionnullwithasnoits detail message. The cause is not initialized and may subsequently be initialized by a call to #initCause
Constructs aRuntimeExceptionnew runtime exception with the specified detail message. The cause is not initialized and may subsequently be initialized by a call to #initCause @paramsmessage the detail message. The detail message is saved for later retrieval by the #getMessage() method.
This class is for runtime permissions. A RuntimePermission contains a name (also referred to as a "target name") but no actions list; you either have the named permission or you don't.The target name is the name of the runtime permission (see below). The naming convention follows the hierarchical property naming convention. Also an asterisk may appear at the end of the name following a "." or by itself to signify a wildcard match. For example: "loadLibrary.*" or "*" is valid "*loadLibrary" or "a*b" is not valid.
The following table lists all the possible RuntimePermission target names and for each provides a description of what the permission allows and a discussion of the risks of granting code the permission.
@see java.security.BasicPermission @see java.security.Permission @see java.security.Permissions @see java.security.PermissionCollection @see java.lang.SecurityManager @version 1.
Permission Target Name What the Permission Allows Risks of Allowing this Permission createClassLoader Creation of a class loader This is an extremely dangerous permission to grant. Malicious applications that can instantiate their own class loaders could then load their own rogue classes into the system. These newly loaded classes could be placed into any protection domain by the class loader thereby automatically granting the classes the permissions for that domain. getClassLoader Retrieval of a class loader (e.g. the class loader for the calling class) This would grant an attacker permission to get the class loader for a particular class. This is dangerous because having access to a class's class loader allows the attacker to load other classes available to that class loader. The attacker would typically otherwise not have access to those classes. setContextClassLoader Setting of the context class loader used by a thread The context class loader is used by system code and extensions when they need to lookup resources that might not exist in the system class loader. Granting setContextClassLoader permission would allow code to change which context class loader is used for a particular thread including system threads. setSecurityManager Setting of the security manager (possibly replacing an existing one) The security manager is a class that allows applications to implement a security policy. Granting the setSecurityManager permission would allow code to change which security manager is used by installing a different possibly less restrictive security manager thereby bypassing checks that would have been enforced by the original security manager. createSecurityManager Creation of a new security manager This gives code access to protected sensitive methods that may disclose information about other classes or the execution stack. exitVM Halting of the Java Virtual Machine This allows an attacker to mount a denial-of-service attack by automatically forcing the virtual machine to halt. Note: The "exitVM" permission is automatically granted to all code loaded from the application class path thus enabling applications to terminate themselves. shutdownHooks Registration and cancellation of virtual-machine shutdown hooks This allows an attacker to register a malicious shutdown hook that interferes with the clean shutdown of the virtual machine. setFactory Setting of the socket factory used by ServerSocket or Socket or of the stream handler factory used by URL This allows code to set the actual implementation for the socket server socket stream handler or RMI socket factory. An attacker may set a faulty implementation which mangles the data stream. setIO Setting of System.out System.in and System.err This allows changing the value of the standard system streams. An attacker may change System.in to monitor and steal user input or may set System.err to a "null" OutputSteam which would hide any error messages sent to System.err. modifyThread Modification of threads e.g. via calls to Thread stop
suspend
resume
setPriority
andsetName
methodsThis allows an attacker to start or suspend any thread in the system. stopThread Stopping of threads via calls to the Thread stop
methodThis allows code to stop any thread in the system provided that it is already granted permission to access that thread. This poses as a threat because that code may corrupt the system by killing existing threads. modifyThreadGroup modification of thread groups e.g. via calls to ThreadGroup destroy
getParent
resume
setDaemon
setMaxPriority
stop
andsuspend
methodsThis allows an attacker to create thread groups and set their run priority. getProtectionDomain Retrieval of the ProtectionDomain for a class This allows code to obtain policy information for a particular code source. While obtaining policy information does not compromise the security of the system it does give attackers additional information such as local file names for example to better aim an attack. readFileDescriptor Reading of file descriptors This would allow code to read the particular file associated with the file descriptor read. This is dangerous if the file contains confidential data. writeFileDescriptor Writing to file descriptors This allows code to write to a particular file associated with the descriptor. This is dangerous because it may allow malicousmalicious code to plant viruses or at the very least fill up your entire disk.loadLibrary.{library name} Dynamic linking of the specified library It is dangerous to allow an applet permission to load native code libraries because the Java security architecture is not designed to and does not prevent malicious behavior at the level of native code. accessClassInPackage.{package name} Access to the specified package via a class loader's loadClass
method when that class loader calls the SecurityManagercheckPackageAcesss
methodThis gives code access to classes in packages to which it normally does not have access. Malicious code may use these classes to help in its attempt to compromise security in the system. defineClassInPackage.{package name} Definition of classes in the specified package via a class loader's defineClass
method when that class loader calls the SecurityManagercheckPackageDefinition
method.This grants code permission to define a class in a particular package. This is dangerous because malicious code with this permission may define rogue classes in trusted packages like java.security
orjava.lang
for example.accessDeclaredMembers Access to the declared members of a class This grants code permission to query a class for its public protected default (package) access and private fields and/or methods. Although the code would have access to the private and protected field and method names it would not have access to the private/protected field data and would not be able to invoke any private methods. Nevertheless malicious code may use this information to better aim an attack. Additionally it may invoke any public methods and/or access public fields in the class. This could be dangerous if the code would normally not be able to invoke those methods and/or access the fields because it can't cast the object to the class/interface with those methods and fields. queuePrintJob Initiation of a print job request This could print sensitive information to a printer or simply waste paper. 37400001/0212/0203 @author Marianne Mueller @author Roland Schemers
Thrown by the security manager to indicate a security violation. @author unascribed @version 1.11 0212 12/0203/0001 @see java.lang.SecurityManager @since JDK1.0
The security manager is a class that allows applications to implement a security policy. It allows an application to determine before performing a possibly unsafe or sensitive operation what the operation is and whether it is being attempted in a security context that allows the operation to be performed. The application can allow or disallow the operation.Class SecurityManager, void checkMulticast(InetAddress, byte)The
SecurityManager
class contains many methods with names that begin with the wordcheck
. These methods are called by various methods in the Java libraries before those methods perform certain potentially sensitive operations. The invocation of such acheck
method typically looks like this:SecurityManager security = System.getSecurityManager(); if (security = null) { security.checkXXX(argument . . . ); }The security manager is thereby given an opportunity to prevent completion of the operation by throwing an exception. A security manager routine simply returns if the operation is permitted but throws a
SecurityException
if the operation is not permitted. The only exception to this convention ischeckTopLevelWindow
which returns aboolean
value.The current security manager is set by the
setSecurityManager
method in classSystem
. The current security manager is obtained by thegetSecurityManager
method.The special method SecurityManager#checkPermission(java.security.Permission) determines whether an access request indicated by a specified permission should be granted or denied. The default implementation calls
AccessController.checkPermission(perm);If a requested access is allowed
checkPermission
returns quietly. If denied aSecurityException
is thrown.As of Java 2 SDK v1.2 the default implementation of each of the other
check
methods inSecurityManager
is to call theSecurityManager checkPermission
method to determine if the calling thread has permission to perform the requested operation.Note that the
checkPermission
method with just a single permission argument always performs security checks within the context of the currently executing thread. Sometimes a security check that should be made within a given context will actually need to be done from within a different context (for example from within a worker thread). The getSecurityContext method and the java.lang.Object checkPermission} method that includes a context argument are provided for this situation. ThegetSecurityContext
method returns a "snapshot" of the current calling context. (The default implementation returns an AccessControlContext object.) A sample call is the following:Object context = null; SecurityManager sm = System.getSecurityManager(); if (sm = null) context = sm.getSecurityContext();The
checkPermission
method that takes a context object in addition to a permission makes access decisions based on that context rather than on that of the current execution thread. Code within a different context can thus call that method passing the permission and the previously-saved context object. A sample call using the SecurityManagersm
obtained as in the previous example is the following:if (sm = null) sm.checkPermission(permission context);Permissions fall into these categories: File Socket Net Security Runtime Property AWT Reflect and Serializable. The classes managing these various permission categories are
java.io.FilePermission
java.net.SocketPermission
java.net.NetPermission
java.security.SecurityPermission
java.lang.RuntimePermission
java.util.PropertyPermission
java.awt.AWTPermission
java.lang.reflect.ReflectPermission
andjava.io.SerializablePermission
.All but the first two (FilePermission and SocketPermission) are subclasses of
java.security.BasicPermission
which itself is an abstract subclass of the top-level class for permissions which isjava.security.Permission
. BasicPermission defines the functionality needed for all permissions that contain a name that follows the hierarchical property naming convention (for example "exitVM" "setFactory" "queuePrintJob" etc). An asterisk may appear at the end of the name following a "." or by itself to signify a wildcard match. For example: "a.*" or "*" is valid "*a" or "a*b" is not valid.FilePermission and SocketPermission are subclasses of the top-level class for permissions (
java.security.Permission
). Classes like these that have a more complicated name syntax than that used by BasicPermission subclass directly from Permission rather than from BasicPermission. For example for ajava.io.FilePermission
object the permission name is thepathnamepath name of a file (or directory).Some of the permission classes have an "actions" list that tells the actions that are permitted for the object. For example for a
java.io.FilePermission
object the actions list (such as "read write") specifies which actions are granted for the specified file (or for files in the specified directory).Other permission classes are for "named" permissions - ones that contain a name but no actions list; you either have the named permission or you don't.
Note: There is also a
java.security.AllPermission
permission that implies all permissions. It exists to simplify the work of system administrators who might need to perform multiple tasks that require all (or numerous) permissions.See Permissions in the Java 2 SDK for permission-related information. This document includes for example a table listing the various SecurityManager
check
methods and the permission(s) the default implementation of each such method requires. It also contains a table of all the version 1.2 methods that require permissions and for each such method tells which permission it requires.For more information about
SecurityManager
changes made in the Java 2 SDK and advice regarding porting of 1.1-style security managers see the security documentation. @author Arthur van Hoff @author Roland Schemers @version 1.121 02127 12/0203/0001 @see java.lang.ClassLoader @see java.lang.SecurityException @see java.lang.SecurityManager#checkTopLevelWindow(java.lang.Object) checkTopLevelWindow @see java.lang.System#getSecurityManager() getSecurityManager @see java.lang.System#setSecurityManager(java.lang.SecurityManager) setSecurityManager @see java.security.AccessController AccessController @see java.security.AccessControlContext AccessControlContext @see java.security.AccessControlException AccessControlException @see java.security.Permission @see java.security.BasicPermission @see java.io.FilePermission @see java.net.SocketPermission @see java.util.PropertyPermission @see java.lang.RuntimePermission @see java.awt.AWTPermission @see java.security.Policy Policy @see java.security.SecurityPermission SecurityPermission @see java.security.ProtectionDomain @since JDK1.0
Throws aClass SecurityManager, boolean checkTopLevelWindow(Object)SecurityException
if the calling thread is not allowed to use (join/leave/send/receive) IP multicast.This method calls
checkPermission
with thejava.net.SocketPermission(maddr.getHostAddress() "accept connect")
permission.If you override this method then you should make a call to
super.checkMulticast
at the point the overridden method would normally throw an exception. @param maddr Internet group address to be used. @param ttl value in use if it is multicast send. Note: this particular implementation does not use the ttl parameter. @exception SecurityException if the calling thread is not allowed to use (join/leave/send/receive) IP multicast. @exception NullPointerException if the address argument isnull
. @since JDK1.1 @deprecated Use #checkPermission(java.security.Permission) instead @see #checkPermission(java.security.Permission) checkPermission
Returnsfalse
if the calling thread is not trusted to bring up the top-level window indicated by thewindow
argument. In this case the caller can still decide to show the window but the window should include some sort of visual warning. If the method returnstrue
then the window can be shown without any special restrictions.See class
Window
for more information on trusted and untrusted windows.This method calls
checkPermission
with theAWTPermission("showWindowWithoutWarningBanner")
permission and returnstrue
if a SecurityException is not thrown otherwise it returnsfalse
.If you override this method then you should make a call to
super.checkTopLevelWindow
at the point the overridden method would normally returnfalse
and the value ofsuper.checkTopLevelWindow
should be returned. @param window the new window that is being created. @returntrue
if the calling thread is trusted to put up top-level windows;false
otherwise. @exceptionSecurityException if creation is disallowed entirely. @exceptionNullPointerException if thewindow
argument isnull
. @see java.awt.Window @see #checkPermission(java.security.Permission) checkPermission
TheClass Short, constructor Short(String)Short
class wraps a value of primitive typeshort
in an object. An object of typeShort
contains a single field whose type istheshort
.In addition
standardthiswrapperclass provides several methods for converting ashort
to aString
and aString
to ashort as well as other constants and
valuesmethods useful when dealing with ashort
. @author Nakul Saraiya @version 1.22 0231 12/0203/0001 @see java.lang.Number @since JDK1.1
Constructs a newly allocatedClass Short, constructor Short(short)Short object
initialized tothat represents theshort
valuespecifiedindicated by theString
parameter. Theradixstring isassumedconverted tobeashort
value in exactly the manner used by theparseShort
method for radix 10. @param s theString
to be converted to aShort
@exception NumberFormatException If theString
does not contain a parsableshort
. @see java.lang.Short#parseShort(java.lang.String int)
Constructs a newly allocatedClass Short, byte byteValue()Short object
initialized tothat represents the specifiedshort
value. @param value theinitialvalueofto be represented by theShort
.
Returns the value of thisClass Short, int compareTo(Object)Short
as abyte
.
Compares thisClass Short, int compareTo(Short)Short
object to anotherObjectobject. If theObjectobject is aShort
this function behaves likecompareTo(Short)
. Otherwise it throws aClassCastException
(asShortsShort
objects arecomparableonly comparable to otherShortsShort
objects). @param o theObject
to be compared. @return the value0
if the argument is aShort
numerically equal to thisShort
; a value less than0
if the argument is aShort
numerically greater than thisShort
; and a value greater than0
if the argument is aShort
numerically less than thisShort
. @exceptionClassCastException
if the argument is not aShort
. @see java.lang.Comparable @since 1.2
Compares twoClass Short, Short decode(String)ShortsShort
objects numerically. @param anotherShort theShort
to be compared. @return the value0
ifthe argumentthisShort
is equal tothisthe argumentShort; a value less than
0
if thisShort
is numerically less than theShortargumentShort
; and a value greater than0
if thisShort
is numerically greater than theShortargumentShort
(signed comparison). @since 1.2
Decodes aClass Short, double doubleValue()String
into aShort
. Accepts decimal hexadecimal and octal numbersingiven by the followingformatsgrammar:[-]DecimalNumeral HexDigits and OctalDigits are defined in §3.10.1 ofdecimal
constant- DecodableString:
[-]- Signopt DecimalNumeral
- Signopt
0x
hexHexDigits- Signopt
constant0X
[-]HexDigits- Signopt
#
HexDigits- Signopt
hex0
constantOctalDigits
- Sign:
[-
] 0octalconstantthe Java Language Specification.The
constantsequence of characters following an (optional) negative sign and/or"radix specifier"("0x
" "0X
" "#
" or leading zero) is parsed as by theShort.parseShort
method with thespecifiedindicated radix (10816 or168). Thisconstantsequence of characters mustberepresent a positive value or a NumberFormatException willresultbe thrown. The result ismadenegatednegativeif first character of the specifiedString
is thenegativeminus sign. No whitespace characters are permitted in theString
. @param nm theString
to decode. @returntheaShort
represented byobject holding thespecifiedshort
string.value represented bynm
@exception NumberFormatException if theString
does not contain a parsableshort
. @see java.lang.Short#parseShort(java.lang.String int)
Returns the value of thisClass Short, boolean equals(Object)Short
as adouble
.
Compares this object to the specified object. The result isClass Short, float floatValue()true
if and only if the argument is notnull
and is aShort
object that contains the sameshort
value as this object. @param obj the object to compare with @returntrue
if the objects are the same;false
otherwise.
Returns the value of thisClass Short, int hashCode()Short
as afloat
.
Returns aClass Short, int intValue()hashcodehash code for thisShort
.
Returns the value of thisClass Short, long longValue()Short
as anint
.
Returns the value of thisClass Short, short parseShort(String)Short
as along
.
Class Short, short parseShort(String, int)AssumingParses thespecifiedstringString representsargument as a signed decimalshort.
returns thatThe charactersshort'sinvalue.theThrows an exceptionstring must allifbe decimal digits except that theString cannotfirst character may beparsedanasASCII minus sign'-'
('\u002D'
) to indicate ashortnegative value. Theradixresultingshort
value isassumed toreturned exactlybeas if the argument and the radix 10 were given as arguments to the int) method. @param stheaString
containing theshort
representation to be parsed @returnshorttheshort
value represented by thespecifiedargumentstringin decimal. @exception NumberFormatException If the string does not contain a parsableshort
.
Class Short, short shortValue()AssumingParses thespecifiedstringString representsargument as a signedshort in the radix specified by the second argument. The characters in the string must all be digits of the specified radix (as determined by whether int) returns a nonnegative value) except that
shortthe first character may be an ASCII minus sign'
s-' ('\u002D'
) to indicate a negative value.ThrowsTheanresultingbyte
value is returned. An exception of typeNumberFormatException
is thrown if any of theStringfollowing situations occurs:
- The first argument is
null
or is a stringcannotof length zero.The radix is either smaller than java.lang.Character#MIN_RADIX or larger than java.lang.Character#MAX_RADIX Any character of the string is not a digit of the specified radix except that the first character may beparsedaasminus sign'-'
('\u002D'
) provided that the string is longer than length 1.The value represented by the string is not a value of typeshort. @param s the
String
containing theshort
representation to be parsed @param radix the radix to be used while parsings
@returnThetheshort
represented by thevaluespecifiedstring argument in the specified radix. @exception NumberFormatException If theString
does not contain a parsableshort
.
Returns the value of thisClass Short, String toString()Short
as ashort
.
Returns aClass Short, String toString(short)String
object representing thisShort
's value. The value is converted to signed decimal representation and returned as a string exactly as if theshort
value were given as an argument to the java.lang.Short#toString(short) method. @return a string representation of the value of this object in base 10.
Returns a newClass Short, Short valueOf(String)String
object representing the specifiedShortshort
. The radix is assumed to be 10. @param s theshort
to be converted @returnThe String that representsthe string representation of the specifiedshort
inradix@see10java.lang.Integer#toString(int)
Class Short, Short valueOf(String, int)AssumingReturns aShort
object holding the value given by the specifiedString
.representsThe argument is interpreted as representing a signed decimalshort
returns a new Shortexactly as if theobjectargument wereinitializedgiven tothatthevalue#parseShort(java.lang.String)Throwsmethod.an exception ifThe result is aShort
object that represents theStringshort
valuecannot be parsedspecified by theasstring.In other words this
method returns ashortByte
object equal to the value of:@param s thenew Short(Short.parseShort(s))
String containing the integerstring to be parsed @return aShort
ofobject holding the value represented by thespecifiedstringin radix 10.argument @exception NumberFormatException If theString
does not contain a parsableshort
.
Class Short, short MAX_VALUEAssumingReturns aShort
object holding the value extracted from the specifiedString
representswhen parsed with the radix given by the second argument. The first argument is interpreted as representing a signedshort
returns a new Shortin the radix specifiedobjectby the second argument exactlyinitializedas if the argument were given tothatthevalueint) method.ThrowsThe resultan exceptionis aifShort
object that represents theStringshort
cannot be parsedvalue specified byasthe string.In other words this method returns
ashortShort
object equal to the value of:@param s thenew Short(Short.parseShort(s radix))
String containing the integerstring to be parsed @param radix the radix to be used in interpretings
@returnTheaShort
object holding the value represented by thespecifiedstring argument in the specified radix. @exception NumberFormatException If theString
does not contain a parsableshort
.
Class Short, short MIN_VALUETheA constant holding the maximum value aShortshort
can have 215-1.
Class Short, Class TYPETheA constant holding the minimum value aShortshort
can have -215.
TheClass
objectinstance representing the primitive typeshort
.
Thrown when a stack overflow occurs because an application recurses too deeply. @author unascribed @version 1.18 0219 12/0203/0001 @since JDK1.0
The classClass StrictMath, double abs(double)StrictMath
contains methods for performing basic numeric operations such as the elementary exponential logarithm square root and trigonometric functions.To help ensure portability of Java programs the definitions of many of the numeric functions in this package require that they produce the same results as certain published algorithms. These algorithms are available from the well-known network library
netlib
as the package "Freely Distributable Math Library" (fdlibm
). These algorithms which are written in the C programming language are then to be understood as executed with all floating-point operations following the rules of Java floating-point arithmetic.The network library may be found on the World Wide Web at:
http://metalab.unc.edu/The Java math library is defined with respect to the version of
fdlibm
dated January 4 1995. Wherefdlibm
provides more than one definition for a function (such asacos
) use the "IEEE 754 core function" version (residing in a file whose name begins with the lettere
). @author unascribed @version 1.9 0213 12/0203/0001 @since 1.3
Returns the absolute value of aClass StrictMath, float abs(float)double
value. If the argument is not negative the argument is returned. If the argument is negative the negation of the argument is returned. Special cases:In other words the result is
- If the argument is positive zero or negative zero the result is positive zero.
- If the argument is infinite the result is positive infinity.
- If the argument is NaN the result is NaN.
equalthetosame as the value of the expression:
Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)
@param aathedoubleargument whose absolute value.is to be determined @return the absolute value of the argument.
Returns the absolute value of aClass StrictMath, int abs(int)float
value. If the argument is not negative the argument is returned. If the argument is negative the negation of the argument is returned. Special cases:In other words the result is
- If the argument is positive zero or negative zero the result is positive zero.
- If the argument is infinite the result is positive infinity.
- If the argument is NaN the result is NaN.
equalthetosame as the value of the expression:Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))@param aathefloatargument whose absolute value.is to be determined @return the absolute value of the argument.
Returns the absolute value of anClass StrictMath, long abs(long)int
value.. If the argument is not negative the argument is returned. If the argument is negative the negation of the argument is returned.Note that if the argument is equal to the value of
Integer.MIN_VALUE
the most negative representableint
value the result is that same value which is negative. @param a theintargument whose absolute value is to be determined. @return the absolute value of the argument. @see java.lang.Integer#MIN_VALUE
Returns the absolute value of aClass StrictMath, double acos(double)long
value. If the argument is not negative the argument is returned. If the argument is negative the negation of the argument is returned.Note that if the argument is equal to the value of
Long.MIN_VALUE
the most negative representablelong
value the result is that same value which is negative. @param aathelongargument whose absolute value is to be determined. @return the absolute value of the argument. @see java.lang.Long#MIN_VALUE
Returns the arc cosine of an angle in the range of 0.0 through pi. Special case:Class StrictMath, double asin(double)@param a the
- If the argument is NaN or its absolute value is greater than 1 then the result is NaN.
doublevalue whose arc cosine is to be returned. @return the arc cosine of the argument.
Returns the arc sine of an angle in the range of -pi/2 through pi/2. Special cases:Class StrictMath, double atan(double)@param a the
- If the argument is NaN or its absolute value is greater than 1 then the result is NaN.
- If the argument is
positivezero then the result ispositivea zero;ifwith theargument is negativesamezero thensign as theresult is negative zeroargument.doublevalue whose arc sine is to be returned. @return the arc sine of the argument.
Returns the arc tangent of an angle in the range of -pi/2 through pi/2. Special cases:Class StrictMath, double atan2(double, double)@param a the
- If the argument is NaN then the result is NaN.
- If the argument is
positivezero then the result ispositivea zero;ifwith theargument is negativesamezero thensign as theresult is negative zeroargument.doublevalue whose arc tangent is to be returned. @return the arc tangent of the argument.
Converts rectangular coordinates (Class StrictMath, double ceil(double)
bx) to polar (r theta). This method computes the phase theta by computing an arc tangent of
ayin the range of -pi to pi. Special cases:
ay/bx@param
- If either argument is NaN then the result is NaN.
- If the first argument is positive zero and the second argument is positive or the first argument is positive and finite and the second argument is positive infinity then the result is positive zero.
- If the first argument is negative zero and the second argument is positive or the first argument is negative and finite and the second argument is positive infinity then the result is negative zero.
- If the first argument is positive zero and the second argument is negative or the first argument is positive and finite and the second argument is negative infinity then the result is the
double
value closest to pi.- If the first argument is negative zero and the second argument is negative or the first argument is negative and finite and the second argument is negative infinity then the result is the
double
value closest to -pi.- If the first argument is positive and the second argument is positive zero or negative zero or the first argument is positive infinity and the second argument is finite then the result is the
double
value closest to pi/2.- If the first argument is negative and the second argument is positive zero or negative zero or the first argument is negative infinity and the second argument is finite then the result is the
double
value closest to -pi/2.- If both arguments are positive infinity then the result is the
double
value closest to pi/4.- If the first argument is positive infinity and the second argument is negative infinity then the result is the
double
value closest to 3*pi/4.- If the first argument is negative infinity and the second argument is positive infinity then the result is the
double
value closest to -pi/4.- If both arguments are negative infinity then the result is the
double
value closest to -3*pi/4.a ay thedoubleordinatevalue.coordinate @paramb ax thedoubleabscissavalue.coordinate @return the theta component of the point (r theta) in polar coordinates that corresponds to the point (bxay) in Cartesian coordinates.
Returns the smallest (closest to negative infinity)Class StrictMath, double cos(double)double
value that is not less than the argument and is equal to a mathematical integer. Special cases:Note that the value of
- If the argument value is already equal to a mathematical integer then the result is the same as the argument.
- If the argument is NaN or an infinity or positive zero or negative zero then the result is the same as the argument.
- If the argument value is less than zero but greater than -1.0 then the result is negative zero.
Math.ceil(x)
is exactly the value of-Math.floor(-x)
. @param a adoublevalue. <--@return the value ⌈a
⌉.--> @return the smallest (closest to negative infinity)doublefloating-point value that is not less than the argument and is equal to a mathematical integer.
Returns the trigonometric cosine of an angle. SpecialClass StrictMath, double exp(double)casecases:@param a an angle in radians. @return the cosine of the argument.
- If the argument is NaN or an infinity then the result is NaN.
ReturnsClass StrictMath, double floor(double)the exponentialEuler's number e(i.e. 2.718...)raised to the power of adouble
value. Special cases:@param a
- If the argument is NaN the result is NaN.
- If the argument is positive infinity then the result is positive infinity.
- If the argument is negative infinity then the result is positive zero.
athedoubleexponentvalueto raise e to. @return the value ea
where e is the base of the natural logarithms.
Returns the largest (closest to positive infinity)Class StrictMath, double max(double, double)double
value that is not greater than the argument and is equal to a mathematical integer. Special cases:@param a a
- If the argument value is already equal to a mathematical integer then the result is the same as the argument.
- If the argument is NaN or an infinity or positive zero or negative zero then the result is the same as the argument.
double
value. <--@return the value ⌊a
⌋.--> @return the largest (closest to positive infinity)doublefloating-point value that is not greater than the argument and is equal to a mathematical integer.
Returns the greater of twoClass StrictMath, float max(float, float)double
values. That is the result is the argument closer to positive infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero the result is positive zero. @param aa doubleanvalueargument. @param ba doubleanothervalueargument. @return the larger ofa
andb
.
Returns the greater of twoClass StrictMath, int max(int, int)float
values. That is the result is the argument closer to positive infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero the result is positive zero. @param aa floatanvalueargument. @param ba floatanothervalueargument. @return the larger ofa
andb
.
Returns the greater of twoClass StrictMath, long max(long, long)int
values. That is the result is the argument closer to the value ofInteger.MAX_VALUE
. If the arguments have the same value the result is that same value. @param a anint valueargument. @param ban intanothervalueargument. @return the larger ofa
andb
. @see java.lang.Long#MAX_VALUE
Returns the greater of twoClass StrictMath, double min(double, double)long
values. That is the result is the argument closer to the value ofLong.MAX_VALUE
. If the argumens have the same value the result is that same value. @param aa longanvalueargument. @param ba longanothervalueargument. @return the larger ofa
andb
. @see java.lang.Long#MAX_VALUE
Returns the smaller of twoClass StrictMath, float min(float, float)double
values. That is the result is the value closer to negative infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero the result is negative zero. @param aa doubleanvalueargument. @param ba doubleanothervalueargument. @return the smaller ofa
andb
.
Returns the smaller of twoClass StrictMath, int min(int, int)float
values. That is the result is the value closer to negative infinity. If the arguments have the same value the result is that same value. If either value is NaN then the result is NaN. Unlike the the numerical comparison operators this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero the result is negative zero. @param aa floatanvalueargument. @param ba floatanothervalueargument. @return the smaller ofa
andb.
Returns the smaller of twoClass StrictMath, long min(long, long)int
values. That is the result the argument closer to the value ofInteger.MIN_VALUE
. If the arguments have the same value the result is that same value. @param a anint valueargument. @param ban intanothervalueargument. @return the smaller ofa
andb
. @see java.lang.Long#MIN_VALUE
Returns the smaller of twoClass StrictMath, double pow(double, double)long
values. That is the result is the argument closer to the value ofLong.MIN_VALUE
. If the arguments have the same value the result is that same value. @param aa longanvalueargument. @param ba longanothervalueargument. @return the smaller ofa
andb
. @see java.lang.Long#MIN_VALUE
Returns of value of the first argument raised to the power of the second argument. Special cases:Class StrictMath, double rint(double)
- If the second argument is positive or negative zero then the result is 1.0.
- If the second argument is 1.0 then the result is the same as the first argument.
- If the second argument is NaN then the result is NaN.
- If the first argument is NaN and the second argument is nonzero then the result is NaN.
- If the absolute value of the first argument is greater than 1 and the second argument is positive infinity or the absolute value of the first argument is less than 1 and the second argument is negative infinity then the result is positive infinity.
- If the absolute value of the first argument is greater than 1 and the second argument is negative infinity or the absolute value of the first argument is less than 1 and the second argument is positive infinity then the result is positive zero.
- If the absolute value of the first argument equals 1 and the second argument is infinite then the result is NaN.
- If the first argument is positive zero and the second argument is greater than zero or the first argument is positive infinity and the second argument is less than zero then the result is positive zero.
- If the first argument is positive zero and the second argument is less than zero or the first argument is positive infinity and the second argument is greater than zero then the result is positive infinity.
- If the first argument is negative zero and the second argument is greater than zero but not a finite odd integer or the first argument is negative infinity and the second argument is less than zero but not a finite odd integer then the result is positive zero.
- If the first argument is negative zero and the second argument is a positive finite odd integer or the first argument is negative infinity and the second argument is a negative finite odd integer then the result is negative zero.
- If the first argument is negative zero and the second argument is less than zero but not a finite odd integer or the first argument is negative infinity and the second argument is greater than zero but not a finite odd integer then the result is positive infinity.
- If the first argument is negative zero and the second argument is a negative finite odd integer or the first argument is negative infinity and the second argument is a positive finite odd integer then the result is negative infinity.
- If the first argument is less than zero and the second argument is a finite even integer then the result is equal to the result of raising the absolute value of the first argument to the power of the second argument.
- If the first argument is less than zero and the second argument is a finite odd integer then the result is equal to the negative of the result of raising the absolute value of the first argument to the power of the second argument.
- If the first argument is finite and less than zero and the second argument is finite and not an integer then the result is NaN.
- If both arguments are integers then the result is exactly equal to the mathematical result of raising the first argument to the power of the second argument if that result can in fact be represented exactly as a double value.
(In the foregoing descriptions a floating-point value is considered to be an integer if and only if it is a fixed point of the method ceil or
whichequivalentlyis the same thinga fixed point of the method floor A value is a fixed point of a one-argument method if and only if the result of applying the method to the value is equal to the value.) @param aa double valuebase. @param ba doublethevalueexponent. @return the valueab
.
Returns theClass StrictMath, long round(double)double
value that is closest in value toathe argument and is equal to a mathematical integer. If twodouble
values that are mathematical integers are equally close to the value of the argument the result is the integer value that is even. Special cases:@param a a
- If the argument value is already equal to a mathematical integer then the result is the same as the argument.
- If the argument is NaN or an infinity or positive zero or negative zero then the result is the same as the argument.
doublevalue. @return the closestdoublefloating-point value toa
that is equal to a mathematical integer.
Returns the closestClass StrictMath, int round(float)long
to the argument. The result is rounded to an integer by adding 1/2 taking the floor of the result and casting the result to typelong
. In other words the result is equal to the value of the expression:(long)Math.floor(a + 0.5d)Special cases:
@param a a
- If the argument is NaN the result is 0.
- If the argument is negative infinity or any value less than or equal to the value of
Long.MIN_VALUE
the result is equal to the value ofLong.MIN_VALUE
.- If the argument is positive infinity or any value greater than or equal to the value of
Long.MAX_VALUE
the result is equal to the value ofLong.MAX_VALUE
.doublefloating-point value to be rounded to along
. @return the value of the argument rounded to the nearestlong
value. @see java.lang.Long#MAX_VALUE @see java.lang.Long#MIN_VALUE
Returns the closestClass StrictMath, double sin(double)int
to the argument. The result is rounded to an integer by adding 1/2 taking the floor of the result and casting the result to typeint
. In other words the result is equal to the value of the expression:(int)Math.floor(a + 0.5f)Special cases:
@param a a
- If the argument is NaN the result is 0.
- If the argument is negative infinity or any value less than or equal to the value of
Integer.MIN_VALUE
the result is equal to the value ofInteger.MIN_VALUE
.- If the argument is positive infinity or any value greater than or equal to the value of
Integer.MAX_VALUE
the result is equal to the value ofInteger.MAX_VALUE
.floatfloating-point value to be rounded to an integer. @return the value of the argument rounded to the nearestint
value. @see java.lang.Integer#MAX_VALUE @see java.lang.Integer#MIN_VALUE
Returns the trigonometric sine of an angle. Special cases:Class StrictMath, double sqrt(double)@param a an angle in radians. @return the sine of the argument.
- If the argument is NaN or an infinity then the result is NaN.
- If the argument is
positivezero then the result ispositivea zero;ifwith theargument is negativesamezero thensign as theresult is negative zeroargument.
Returns the correctly rounded positive square root of aClass StrictMath, double tan(double)double
value. Special cases:Otherwise the result is the
- If the argument is NaN or less than zero then the result is NaN.
- If the argument is positive infinity then the result is positive infinity.
- If the argument is positive zero or negative zero then the result is the same as the argument.
double
value closest to the true mathetmatical square root of the argument value. @param a adoublevalue. <--@return the value of √a
.--> @return the positive square root ofa
.
Returns the trigonometric tangent of an angle. Special cases:Class StrictMath, double toDegrees(double)@param a an angle in radians. @return the tangent of the argument.
- If the argument is NaN or an infinity then the result is NaN.
- If the argument is
positivezero then the result ispositivea zero;ifwith theargument is negativesamezero thensign as theresult is negative zeroargument.
Converts an angle measured in radians toClass StrictMath, double toRadians(double)thean approximately equivalent angle measured in degrees. The conversion from radians to degrees is generally inexact; users should not expectcos(toRadians(90.0))
to exactly equal0.0
. @param angrad an angle in radians @return the measurement of the angleangrad
in degrees.
Converts an angle measured in degrees toClass StrictMath, double Ethean approximately equivalent angle measured in radians. The conversion from degrees to radians is generally inexact. @param angdeg an angle in degrees @return the measurement of the angleangdeg
in radians.
The double
value that is closer than any other to e the base of the natural logarithms.
TheClass String, constructor String(String)String
class represents character strings. All string literals in Java programs such as"abc"
are implemented as instances of this class.Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:
String str = "abc";is equivalent to:
char data[] = {'a' 'b' 'c'}; String str = new String(data);Here are some more examples of how strings can be used:
System.out.println("abc"); String cde = "cde"; System.out.println("abc" + cde); String c = "abc".substring(2 3); String d = cde.substring(1 2);The class
String
includes methods for examining individual characters of the sequence for comparing strings for searching strings for extracting substrings and for creating a copy of a string with all characters translated to uppercase or to lowercase. Case mapping relies heavily on the information provided by the Unicode Consortium's Unicode 3.0 specification. The specification's UnicodeData.txt and SpecialCasing.txt files are used extensively to provide case mapping.The Java language provides special support for the string concatentation operator ( + ) and for conversion of other objects to strings. String concatenation is implemented through the
StringBuffer
class and itsappend
method. String conversions are implemented through the methodtoString
defined byObject
and inherited by all classes in Java. For additional information on string concatenation and conversion see Gosling Joy and Steele The Java Language Specification. @author Lee Boynton @author Arthur van Hoff @version 1.130 02150 01/0912/0103 @see java.lang.Object#toString() @see java.lang.StringBuffer @see java.lang.StringBuffer#append(boolean) @see java.lang.StringBuffer#append(char) @see java.lang.StringBuffer#append(char[]) @see java.lang.StringBuffer#append(char[] int int) @see java.lang.StringBuffer#append(double) @see java.lang.StringBuffer#append(float) @see java.lang.StringBuffer#append(int) @see java.lang.StringBuffer#append(long) @see java.lang.StringBuffer#append(java.lang.Object) @see java.lang.StringBuffer#append(java.lang.String) @seeCharacter encodingsjava.nio.charset.Charset @since JDK1.0
Initializes a newly createdClass String, constructor String(byte[])String
object so that it represents the same sequence of characters as the argument; in other words the newly created string is a copy of the argument string. @paramvalueoriginal aString
.
Class String, constructor String(byte[], String)ConstructConstructs a new String byconvertingdecoding the specified array of bytes using the platform's defaultcharacter encodingcharset. The length of the new String is a function of theencodingcharset and hence may not be equal to the length of the byte array.The behavior of this constructor when the given bytes are not valid in the default charset is unspecified. The java.nio.charset.CharsetDecoder class should be used when more control over the decoding process is required. @param bytes
Thethe bytes to beconverteddecoded into characters @since JDK1.1
Class String, constructor String(byte[], int)ConstructConstructs a new String byconvertingdecoding the specified array of bytes using the specifiedcharacter encodingcharset. The length of the new String is a function of theencodingcharset and hence may not be equal to the length of the byte array.The behavior of this constructor when the given bytes are not valid in the given charset is unspecified. The java.nio.charset.CharsetDecoder class should be used when more control over the decoding process is required. @param bytes
Thethe bytes to beconverteddecoded into characters @paramenc ThecharsetName the name of a supportedcharacter encodingcharset@exception UnsupportedEncodingException If the named
encodingcharset is not supported @exception NullPointerException If charsetName is null @since JDK1.1
Allocates a newClass String, constructor String(byte[], int, int)String
containing characters constructed from an array of 8-bit integer values. Each character cin the resulting string is constructed from the corresponding component b in the byte array such that:@deprecated This method does not properly convert bytes into characters. As of JDK 1.1 the preferred way to do this is via thec == (char)(((hibyte & 0xff) << 8) | (b & 0xff))String
constructors that take acharacter-encodingcharset name or that use the platform's defaultencodingcharset. @param ascii the bytes to be converted to characters. @param hibyte the top 8 bits of each 16-bit Unicode character. @exception NullPointerException Ifascii
isnull
. @see java.lang.String#String(byte[] int int java.lang.String) @see java.lang.String#String(byte[] int int) @see java.lang.String#String(byte[] java.lang.String) @see java.lang.String#String(byte[])
Class String, constructor String(byte[], int, int, String)ConstructConstructs a new String byconvertingdecoding the specified subarray of bytes using the platform's defaultcharacter encodingcharset. The length of the new String is a function of theencodingcharset and hence may not be equal to the length of the subarray.The behavior of this constructor when the given bytes are not valid in the default charset is unspecified. The java.nio.charset.CharsetDecoder class should be used when more control over the decoding process is required. @param bytes
Thethe bytes to beconverteddecoded into characters @param offsetIndexthe index of the first byte toconvertdecode @param lengthNumberthe number of bytes toconvertdecode @since JDK1.1
Class String, constructor String(byte[], int, int, int)ConstructConstructs a new String byconvertingdecoding the specified subarray of bytes using the specifiedcharacter encodingcharset. The length of the new String is a function of theencodingcharset and hence may not be equal to the length of the subarray.The behavior of this constructor when the given bytes are not valid in the given charset is unspecified. The java.nio.charset.CharsetDecoder class should be used when more control over the decoding process is required. @param bytes
Thethe bytes to beconverteddecoded into characters @param offsetIndexthe index of the first byte toconvertdecode @param lengthNumberthe number of bytes toconvertdecode @paramenccharsetNameThethe name of a supportedcharacter encodingcharset@throws UnsupportedEncodingException if the named
encodingcharset is not supported @throws IndexOutOfBoundsException if the offset andcountlength arguments index characters outside the bounds of the value array.@throws NullPointerException if charsetName is null @since JDK1.1
Allocates a newClass String, int compareTo(String)String
constructed from a subarray of an array of 8-bit integer values.The
offset
argument is the index of the first byte of the subarray and thecount
argument specifies the length of the subarray.Each
byte
in the subarray is converted to achar
as specified in the method above. @deprecated This method does not properly convert bytes into characters. As of JDK 1.1 the preferred way to do this is via theString
constructors that take acharacter-encodingcharset name or that use the platform's defaultencodingcharset. @param ascii the bytes to be converted to characters. @param hibyte the top 8 bits of each 16-bit Unicode character. @param offset the initial offset. @param count the length. @exception IndexOutOfBoundsException if theoffset
orcount
argument is invalid. @exception NullPointerException ifascii
isnull
. @see java.lang.String#String(byte[] int) @see java.lang.String#String(byte[] int int java.lang.String) @see java.lang.String#String(byte[] int int) @see java.lang.String#String(byte[] java.lang.String) @see java.lang.String#String(byte[])
Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by thisClass String, String copyValueOf(char[])String
object is compared lexicographically to the character sequence represented by the argument string. The result is a negative integer if thisString
object lexicographically precedes the argument string. The result is a positive integer if thisString
object lexicographically follows the argument string. The result is zero if the strings are equal;compareTo
returns0
exactly when the #equals(Object) method would returntrue
.This is the definition of lexicographic ordering. If two strings are different then either they have different characters at some index that is a valid index for both strings or their lengths are different or both. If they have different characters at one or more index positions let k be the smallest such index; then the string whose character at position k has the smaller value as determined by using the < operator lexicographically precedes the other string. In this case
compareTo
returns the difference of the two character values at positionk
in the two string -- that is the value:If there is no index position at which they differ then the shorter string lexicographically precedes the longer string. In this casethis.charAt(k)-anotherString.charAt(k)compareTo
returns the difference of the lengths of the strings -- that is the value:@param anotherString thethis.length()-anotherString.length()String
to be compared. @return the value0
if the argument string is equal to this string; a value less than0
if this string is lexicographically less than the string argument; and a value greater than0
if this string is lexicographically greater than the string argument. @exception java.lang.NullPointerException ifanotherString
isnull
.
Returns a String thatClass String, String copyValueOf(char[], int, int)isrepresentsequivalent tothespecifiedcharacterarray. It creates a new array andsequencecopiesin thecharacters intoarrayitspecified. @param data the character array. @return aString
that contains the characters of the character array.
Returns a String thatClass String, byte[] getBytes()isrepresentsequivalent tothespecifiedcharacterarray. It creates a new array andsequencecopiesin thecharacters intoarrayitspecified. @param data the character array. @param offset initial offset of the subarray. @param count length of the subarray. @return aString
that contains the characters of the specified subarray of the character array.
Class String, byte[] getBytes(String)ConvertEncodes this String intobytesa sequence ofaccording tobytes using the platform's defaultcharacter encodingcharset storing the result into a new byte array.The behavior of this method when this string cannot be encoded in the default charset is unspecified. The java.nio.charset.CharsetEncoder class should be used when more control over the encoding process is required. @return
theThe resultant byte array.@since JDK1.1
Class String, void getBytes(int, int, byte[], int)ConvertEncodes this String intobytesaaccording to the specified charactersequence of bytes using theencodingnamed charset storing the result into a new byte array.The behavior of this method when this string cannot be encoded in the given charset is unspecified. The java.nio.charset.CharsetEncoder class should be used when more control over the encoding process is required. @param
enc ThecharsetName the name of a supportedcharacter encodingcharset@return The resultant byte array @exception UnsupportedEncodingException If the named
encodingcharset is not supported @since JDK1.1
Copies characters from this string into the destination byte array. Each byte receives the 8 low-order bits of the corresponding character. The eight high-order bits of each character are not copied and do not participate in the transfer in any way.Class String, int hashCode()The first character to be copied is at index
srcBegin
; the last character to be copied is at indexsrcEnd-1
. The total number of characters to be copied issrcEnd-srcBegin
. The characters converted to bytes are copied into the subarray ofdst
starting at indexdstBegin
and ending at index:@deprecated This method does not properly convert characters into bytes. As of JDK 1.1 the preferred way to do this is via thedstbegin + (srcEnd-srcBegin) - 1getBytes(String enc) method which takes a character-encoding name orthegetBytes()
method which uses the platform's defaultencodingcharset. @param srcBegin index of the first character in the string to copy. @param srcEnd index after the last character in the string to copy. @param dst the destination array. @param dstBegin the start offset in the destination array. @exception IndexOutOfBoundsException if any of the following is true:@exception NullPointerException if
srcBegin
is negativesrcBegin
is greater thansrcEnd
srcEnd
is greater than the length of this StringdstBegin
is negativedstBegin+(srcEnd-srcBegin)
is larger thandst.length
dst
isnull
Returns aClass String, int indexOf(String, int)hashcodehash code for this string. Thehashcodehash code for aString
object is computed asusings[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]int
arithmetic wheres[i]
is the ith character of the stringn
is the length of the string and^
indicates exponentiation. (The hash value of the empty string is zero.) @return a hash code value for this object.
Returns the index within this string of the first occurrence of the specified substring starting at the specified index. The integer returned is the smallest value kClass String, int indexOf(int, int)such thatfor which:thisk >= Math.startsWithmin(strfromIndexkstr.length()) && this.startsWith(k =strfromIndexk)is true. There isIf norestriction on thesuch value offromIndex. If it is negative it has the same effect as if it were zero: this entire string may be searched. If it is greater than the length of this string it has the same effect as if it were equal to the length ofkthisexistsstring:then -1 is returned. @param str the substring for which to searchfor. @param fromIndex the index from which to start the searchfrom. @returnIfthestring argument occurs as a substringindex within thisobject at a starting index no smaller than fromIndex then the indexstring of the firstcharacteroccurrence of thefirst such substring is returned. If it does not occur as aspecified substring starting atfromIndex or beyond -1theis returnedspecified index. @exception java.lang.NullPointerException ifstr
isnull
.
Returns the index within this string of the first occurrence of the specified character starting the search at the specified index.Class String, String intern()If a character with value
ch
occurs in the character sequence represented by thisString
object at an index no smaller thanfromIndex
then the index of the first such occurrence is returned--that is the smallest value k such that:is true. If no such character occurs in this string at or after position(this.charAt(k) == ch) && (k >= fromIndex)
fromIndex
then-1
is returned.There is no restriction on the value of
fromIndex
. If it is negative it has the same effect as if it were zero: this entire string may be searched. If it is greater than the length of this string it has the same effect as if it were equal to the length of this string:-1
is returned. @param ch a character. @param fromIndex the index to start the search from. @return the index of the first occurrence of the character in the character sequence represented by this object that is greater than or equal tofromIndex
or-1
if the character does not occur.
Returns a canonical representation for the string object.Class String, int lastIndexOf(String, int)A pool of strings initially empty is maintained privately by the class
String
.When the intern method is invoked if the pool already contains a string equal to this
String
object as determined by the #equals(Object) method then the string from the pool is returned. Otherwise thisString
object is added to the pool and a reference to thisString
object is returned.It follows that for any two strings
s
andt
s.intern() == t.intern()
istrue
if and only ifs.equals(t)
istrue
.All literal strings and string-valued constant expressions are interned. String literals are defined in
#§3.10.5 of the Java Language Specification @return a string that has the same contents as this string but is guaranteed to be from a pool of unique strings.
Returns the index within this string of the last occurrence of the specified substringClass String, int lastIndexOf(int, int). The returned indexindicates the start ofsearching backward starting at thesubstring and it must be equal to or less thanspecifiedfromIndexindex.That is theTheindexinteger returned is the largest value k such that:If no such value of k exists then -1 is returned. @param str the substring to search for. @param fromIndex the index to start the search from.thisk <= Math.startsWithmin(strfromIndexkstr.length()) && this.startsWith(kstrfromIndexk)There is no restriction on the value of fromIndex. If it is greater than the length of this string it has the same effect as if it were equal to the length of this string: this entire string may be searched. If it is negative it has the same effect as if it were -1: -1 is returned.@returnIfthestring argument occurs one or more times as a substringindex within thisobject at a starting index no greater than fromIndex then the indexstring of thefirst characterlast occurrence of thelast such substring is returned. If it does not occur as aspecified substringstarting at fromIndex or earlier -1 is returned. @exception java.lang.NullPointerException ifstr
isnull
.
Returns the index within this string of the last occurrence of the specified character searching backward starting at the specified index. That is the index returned is the largest value k such that:Class String, boolean regionMatches(int, String, int, int)is true. @param ch a character. @param fromIndex the index to start the search from. There is no restriction on the value ofthis.charAt(k) == ch) && (k <= fromIndex)
fromIndex
. If it is greater than or equal to the length of this string it has the same effect as if it were equal to one less than the length of this string: this entire string may be searched. If it is negative it has the same effect as if it were -1: -1 is returned. @return the index of the last occurrence of the character in the character sequence represented by this object that is less than or equal tofromIndex
or-1
if the character does not occur before that point.
Tests if two string regions are equal.Class String, boolean startsWith(String)A substring of this String object is compared to a substring of the argument other. The result is true if these substrings represent identical character sequences. The substring of this String object to be compared begins at index toffset and has length len. The substring of other to be compared begins at index ooffset and has length len. The result is false if and only if at least one of the following is true:
@param toffset the starting offset of the subregion in this string. @param other the string argument. @param ooffset the starting offset of the subregion in the string argument. @param len the number of characters to compare. @return
- toffset is negative.
- ooffset is negative.
- toffset+len is greater than the length of this String object.
- ooffset+len is greater than the length of the other argument.
- There is some nonnegative integer k less than len such that: this.charAt(toffset+k) = other.charAt(ooffset+k)
true
if the specified subregion of this string exactly matches the specified subregion of the string argument;false
otherwise. @exception java.lang.NullPointerException if other is null.
Tests if this string starts with the specified prefix. @param prefix the prefix. @returnClass String, String toLowerCase()true
if the character sequence represented by the argument is a prefix of the character sequence represented by this string;false
otherwise. Note also thattrue
will be returned if the argument is an empty string or is equal to thisString
object as determined by the #equals(Object) method. @exception java.lang.NullPointerException ifprefix
isnull
. @sinceJDK11. 0
Converts all of the characters in thisClass String, String toLowerCase(Locale)String
to lower case using the rules of the default localewhich is returned by Locale.getDefault.If no character in the string has a different lowercase version based on calling the toLowerCase method definedThisby Character then the original stringisreturned. Otherwise this method creates a new String object that represents a character sequence identical in length to the characterequivalentsequence represented by this String object with every character equal to the result of applying the method Character.toLowerCasetothe corresponding character of thiscalling.
String object. Examples: "French Fries".toLowerCase() returns "french fries" ""Locale.toLowerCasegetDefault()returns "")@return the
stringString
converted to lowercase. @see java.lang.Character#toLowerCase(char) @see java.lang.String#toLowerCase(Locale)
Converts all of the characters in thisClass String, String toUpperCase()String
to lower case using the rules of the givenLocale
.UsuallyCase mappings rely heavily on thecharactersUnicode specification's character data. Since case mappings areconvertednot alwaysby1:1 char mappings thecallingresultingmay be a different length than the original
Character.toLowerCaseStringString
.Exceptions to this rule are listedExamples of lowercase mappings are in the following table:
@param locale use the case transformation rules for this locale @return the
Language Code of Locale Upper Case Lower Case Description tr (Turkish) \u0130 \u0069 capital letter I with dot above -> small letter i tr (Turkish) \u0049 \u0131 capital letter I -> small letter dotless i (all) French Fries french fries lowercased all chars in String (all) lowercased all chars in String String
converted to lowercase. @see java.lang.CharacterString#toLowerCase(char) @see java.lang.String#toUpperCase() @see java.lang.String#toUpperCase(Locale) @sinceJDK11.1
Converts all of the characters in thisClass String, String toUpperCase(Locale)String
to upper case using the rules of the default localewhich is returned by Locale.getDefault.If no character in this stringThishas a different uppercase version based on calling the toUpperCasemethoddefined by Character then the original stringisreturned. Otherwise this method creates a new String object representing a character sequence identical in length to the character sequence represented by this String object and with every character equal to the result of applying the method Character.toUpperCaseequivalent tothe corresponding character of this.
String object. Examples: "Fahrvergnügen".toUpperCase() returns "FAHRVERGNÜGEN" "Visit Ljubinje "Locale.toUpperCasegetDefault()returns "VISIT LJUBINJE ")@return the
stringString
converted to uppercase. @see java.lang.Character#toUpperCase(char) @see java.lang.String#toUpperCase(Locale)
Converts all of the characters in thisClass String, String trim()String
to upper case using the rules of the givenlocaleLocale
.UsuallyCase mappings rely heavily on thecharactersUnicode specification's character data. Since case mappings areconvertednot always 1:1 char mappingsby callingthe resultingmay be a different length than the original
Character.toUpperCaseStringString
.Exceptions to thisExamples of
rulelocale-sensitiveareand 1:Mlistedcase mappings are in the following table:.
@param locale use the case transformation rules for this locale @return the
Language Code of Locale Lower Case Upper Case Description tr (Turkish) \u0069 \u0130 small letter i -> capital letter I with dot above tr (Turkish) \u0131 \u0049 small letter dotless i -> capital letter I (all) \u00df \u0053 \u0053 small letter sharp s -> two letters: SS (all) Fahrvergnügen FAHRVERGNÜGEN String
converted to uppercase. @see java.lang.CharacterString#toUpperCase(char) @see java.lang.String#toLowerCase() @see java.lang.String#toLowerCase(Locale) @sinceJDK11.1
Class String, String valueOf(char)Removes white space from both ends of thisReturns a copy of the string with leadingstringand trailing whitespace omitted.If this
String
object represents an empty character sequence or the first and last characters of character sequence represented by thisString
object both have codes greater than'\u0020'
(the space character) then a reference to thisString
object is returned.Otherwise if there is no character with a code greater than
'\u0020'
in the string then a newString
object representing an empty string is created and returned.Otherwise let k be the index of the first character in the string whose code is greater than
'\u0020'
and let m be the index of the last character in the string whose code is greater than'\u0020'
. A newString
object is created representing the substring of this string that begins with the character at index k and ends with the character at index m-that is the result ofthis.substring(k m+1)
.This method may be used to trim whitespace from the beginning and end of a string; in fact it trims all ASCII control characters as well. @return A copy of this string with leading and trailing white space removed
from the front andor this string ifendit has no leading or trailing white space.
Returns the string representation of theClass String, String valueOf(char[], int, int)char
argument. @param c achar
. @return anewly allocatedstring of length1
containing as its single character the argumentc
.
Returns the string representation of a specific subarray of theClass String, String valueOf(double)char
array argument.The
offset
argument is the index of the first character of the subarray. Thecount
argument specifies the length of the subarray. The contents of the subarray are copied; subsequent modification of the character array does not affect the newly created string. @param data the character array. @param offset the initial offset into the value of theString
. @param count the length of the value of theString
. @return anewly allocatedstring representing the sequence of characters contained in the subarray of the character array argument. @exception NullPointerException ifdata
isnull
. @exception IndexOutOfBoundsException ifoffset
is negative orcount
is negative oroffset+count
is larger thandata.length
.
Returns the string representation of theClass String, String valueOf(float)double
argument.The representation is exactly the one returned by the
Double.toString
method of one argument. @param d adouble
. @return anewly allocated string containing astring representation of thedouble
argument. @see java.lang.Double#toString(double)
Returns the string representation of theClass String, String valueOf(int)float
argument.The representation is exactly the one returned by the
Float.toString
method of one argument. @param f afloat
. @return anewly allocated string containing astring representation of thefloat
argument. @see java.lang.Float#toString(float)
Returns the string representation of theClass String, String valueOf(long)int
argument.The representation is exactly the one returned by the
Integer.toString
method of one argument. @param i anint
. @return anewly allocated string containing astring representation of theint
argument. @see java.lang.Integer#toString(int int)
Returns the string representation of theClass String, Comparator CASE_INSENSITIVE_ORDERlong
argument.The representation is exactly the one returned by the
Long.toString
method of one argument. @param l along
. @return anewly allocated string containing astring representation of thelong
argument. @see java.lang.Long#toString(long)
ReturnsAaComparator that ordersString
objects as bycompareToIgnoreCase
. This comparator is serializable.Note that this Comparator does not take locale into account and will result in an unsatisfactory ordering for certain locales. The java.text package provides Collators to allow locale-sensitive ordering. @
return Comparator for case insensitive comparison of strings @see java.text.Collator#compare(String String) @since 1.2
A string buffer implements a mutable sequence of characters. A string buffer is like a String but can be modified. At any point in time it contains some particular sequence of characters but the length and content of the sequence can be changed through certain method calls.Class StringBuffer, StringBuffer reverse()String buffers are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is consistent with the order of the method calls made by each of the individual threads involved.
String buffers are used by the compiler to implement the binary string concatenation operator
+
. For example the code:x = "a" + 4 + "c"is compiled to the equivalent of:
which creates a new string buffer (initially empty) appends the string representation of each operand to the string buffer in turn and then converts the contents of the string buffer to a string. Overall this avoids creating many temporary strings.x = new StringBuffer().append("a").append(4).append("c") .toString()The principal operations on a
StringBuffer
are theappend
andinsert
methods which are overloaded so as to accept data of any type. Each effectively converts a given datum to a string and then appends or inserts the characters of that string to the string buffer. Theappend
method always adds these characters at the end of the buffer; theinsert
method adds the characters at a specified point.For example if
z
refers to a string buffer object whose current contents are "start
" then the method callz.append("le")
would cause the string buffer to contain "startle
" whereasz.insert(4 "le")
would alter the string buffer to contain "starlet
".In general if sb refers to an instance of a
StringBuffer
thensb.append(x)
has the same effect assb.insert(sb.length() x)
.Every string buffer has a capacity. As long as the length of the character sequence contained in the string buffer does not exceed the capacity it is not necessary to allocate a new internal buffer array. If the internal buffer overflows it is automatically made larger. @author Arthur van Hoff @version 1.
62 0470 12/2103/0001 @see java.io.ByteArrayOutputStream @see java.lang.String @since JDK1.0
The character sequence contained in this string buffer is replaced by the reverse of the sequence.Let n be the length of the old character sequence the one contained in the string buffer just prior to execution of the
reverse
method. Then the character at index k in the new character sequence is equal to the character at index n-k-1 in the old character sequence. @return a reference to thisStringBuffer
object..@since JDK1.0.2
Thrown bythe charAt method in class String and by otherString
methods to indicate that an index is either negative or greater thanorthe size of the string. For some methods such as the charAt method this exception also is thrown when the index is equal to the size of the string. @author unascribed @version 1.18 0220 12/0203/0001 @see java.lang.String#charAt(int) @since JDK1.0
TheClass System, void arraycopy(Object, int, Object, int, int)System
class contains several useful class fields and methods. It cannot be instantiated.Among the facilities provided by the
System
class are standard input standard output and error output streams; access to externally defined "properties"; a means of loading files and libraries; and a utility method for quickly copying a portion of an array. @author Arthur van Hoff @version 1.111 02125 12/0203/0001 @since JDK1.0
Copies an array from the specified source array beginning at the specified position to the specified position of the destination array. A subsequence of array components are copied from the source array referenced byClass System, long currentTimeMillis()src
to the destination array referenced by. The number of components copied is equal to the
dstdestlength
argument. The components at positionsthrough
srcOffsetsrcPosin the source array are copied into positions
srcOffsetsrcPos+length-1through
dstOffsetdestPosrespectively of the destination array.
dstOffsetdestPos+length-1If the
src
andarguments refer to the same array object then the copying is performed as if the components at positions
dstdestthrough
srcOffsetsrcPoswere first copied to a temporary array with
srcOffsetsrcPos+length-1length
components and then the contents of the temporary array were copied into positionsthrough
dstOffsetdestPosof the destination array.
dstOffsetdestPos+length-1If
is
dstdestnull
then aNullPointerException
is thrown.If
src
isnull
then aNullPointerException
is thrown and the destination array is not modified.Otherwise if any of the following is true an
ArrayStoreException
is thrown and the destination is not modified:
- The
src
argument refers to an object that is not an array.- The
argument refers to an object that is not an array.
dstdest- The
src
argument andargument refer to arrays whose component types are different primitive types.
dstdest- The
src
argument refers to an array with a primitive component type and theargument refers to an array with a reference component type.
dstdest- The
src
argument refers to an array with a reference component type and theargument refers to an array with a primitive component type.
dstdestOtherwise if any of the following is true an
IndexOutOfBoundsException
is thrown and the destination is not modified:
- The
argument is negative.
srcOffsetsrcPos- The
argument is negative.
dstOffsetdestPos- The
length
argument is negative.is greater than
srcOffsetsrcPos+lengthsrc.length
the length of the source array.is greater than
dstOffsetdestPos+lengththe length of the destination array.
dstdest.lengthOtherwise if any actual component of the source array from position
through
srcOffsetsrcPoscannot be converted to the component type of the destination array by assignment conversion an
srcOffsetsrcPos+length-1ArrayStoreException
is thrown. In this case let k be the smallest nonnegative integer less than length such thatsrc[
ksrcOffsetsrcPos+]
cannot be converted to the component type of the destination array; when the exception is thrown source array components from positionsthrough
srcOffsetsrcPosk
srcOffsetsrcPos+-1
will already have been copied to destination array positionsthrough
dstOffsetdestPosk
dstOffsetdestPos+-1
and no other positions of the destination array will have been modified. (Because of the restrictions already itemized this paragraph effectively applies only to the situation where both arrays have component types that are reference types.) @param src the source array. @paramsrc_positionsrcPosstartstarting position in the source array. @paramdstdest the destination array. @paramdst_position posdestPosstartstarting position in the destination data. @param length the number of array elements to be copied. @exception IndexOutOfBoundsException if copying would cause access of data outside array bounds. @exception ArrayStoreException if an element in thesrc
array could not be stored into thedest
array because of a type mismatch. @exception NullPointerException if eithersrc
oris
dstdestnull
.
Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond the granularity of the value depends on the underlying operating system and may be larger. For example many operating systems measure time in units of tens of milliseconds.Class System, Properties getProperties()See the description of the class
Date
for a discussion of slight discrepancies that may arise between "computer time" and coordinated universal time (UTC). @return the difference measured in milliseconds between the current time and midnight January 1 1970 UTC. @see java.util.Date
Determines the current system properties.Class System, int identityHashCode(Object)First if there is a security manager its
checkPropertiesAccess
method is called with no arguments. This may result in a security exception.The current set of system properties for use by the #getProperty(String) method is returned as a
Properties
object. If there is no current set of system properties a set of system properties is first created and initialized. This set of system properties always includes values for the following keys:
Key Description of Associated Value java.version
Java Runtime Environment version java.vendor
Java Runtime Environment vendor java.vendor.url
Java vendor URL java.home
Java installation directory java.vm.specification.version
Java Virtual Machine specification version java.vm.specification.vendor
Java Virtual Machine specification vendor java.vm.specification.name
Java Virtual Machine specification name java.vm.version
Java Virtual Machine implementation version java.vm.vendor
Java Virtual Machine implementation vendor java.vm.name
Java Virtual Machine implementation name java.specification.version
Java Runtime Environment specification version java.specification.vendor
Java Runtime Environment specification vendor java.specification.name
Java Runtime Environment specification name java.class.version
Java class format version number java.class.path
Java class path java.library.path
List of paths to search when loading libraries java.io.tmpdir
Default temp file path java.compiler
Name of JIT compiler to use java.ext.dirs
Path of extension directory or directories os.name
Operating system name os.arch
Operating system architecture os.version
Operating system version file.separator
File separator ("/" on UNIX) path.separator
Path separator (":" on UNIX) line.separator
Line separator ("\n" on UNIX) user.name
User's account name user.home
User's home directory user.dir
User's current working directory Multiple paths in a system property value are separated by the path separator character of the platform.
Note that even if the security manager does not permit the
getProperties
operation it may choose to permit the #getProperty(String) operation. @return the system properties @exception SecurityException if a security manager exists and itscheckPropertiesAccess
method doesn't allow access to the system properties. @see #setProperties @see java.lang.SecurityException @see java.lang.SecurityManager#checkPropertiesAccess() @see java.util.Properties
Returns the sameClass System, void load(String)hashcodehash code for the given object as would be returned by the default method hashCode() whether or not the given object's class overrides hashCode(). Thehashcodehash code for the null reference is zero. @param x object for which the hashCode is to be calculated @return the hashCode @since JDK1.1
Loads a code file with the specified filename from the local file system as a dynamic library. The filename argument must be a completepathnamepath name.The call
System.load(name)
is effectively equivalent to the call:@param filename the file to load. @exception SecurityException if a security manager exists and itsRuntime.getRuntime().load(name)checkLink
method doesn't allow loading of the specified dynamic library @exception UnsatisfiedLinkError if the file does not exist. @see java.lang.Runtime#load(java.lang.String) @see java.lang.SecurityManager#checkLink(java.lang.String)
A thread is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.Class Thread, constructor Thread()Every thread has a priority. Threads with higher priority are executed in preference to threads with lower priority. Each thread may or may not also be marked as a daemon. When code running in some thread creates a new
Thread
object the new thread has its priority initially set equal to the priority of the creating thread and is a daemon thread if and only if the creating thread is a daemon.When a Java Virtual Machine starts up there is usually a single non-daemon thread (which typically calls the method named
main
of some designated class). The Java Virtual Machine continues to execute threads until either of the following occurs:
- The
exit
method of classRuntime
has been called and the security manager has permitted the exit operation to take place.- All threads that are not daemon threads have died either by returning from the call to the
run
method or by throwing an exception that propagates beyond therun
method.There are two ways to create a new thread of execution. One is to declare a class to be a subclass of
Thread
. This subclass should override therun
method of classThread
. An instance of the subclass can then be allocated and started. For example a thread that computes primes larger than a stated value could be written as follows:class PrimeThread extends Thread { long minPrime; PrimeThread(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime . . . } }
The following code would then create a thread and start it running:
PrimeThread p = new PrimeThread(143); p.start();The other way to create a thread is to declare a class that implements the
Runnable
interface. That class then implements therun
method. An instance of the class can then be allocated passed as an argument when creatingThread
and started. The same example in this other style looks like the following:class PrimeRun implements Runnable { long minPrime; PrimeRun(long minPrime) { this.minPrime = minPrime; } public void run() { // compute primes larger than minPrime . . . } }
The following code would then create a thread and start it running:
PrimeRun p = new PrimeRun(143); new Thread(p).start();Every thread has a name for identification purposes. More than one thread may have the same name. If a name is not specified when a thread is created a new name is generated for it. @author unascribed @version 1.
107 08125 12/2503/01 @see java.lang.Runnable @see java.lang.Runtime#exit(int) @see java.lang.Thread#run() @see java.lang.Thread#stop() @since JDK1.0
Allocates a newClass Thread, constructor Thread(ThreadGroup, Runnable, String)Thread
object. This constructor has the same effect asThread(null null
gname)
where gname is a newly generated name. Automatically generated names are of the form"Thread-"+
n where n is an integer.Threads created this way must have overridden their run() method to actually do anything. An example illustrating this method being used follows: import java.lang.*; class plain01 implements Runnable { String name; plain01() { name = null; } plain01(String s) { name = s; } public void run() { if (name == null) System.out.println("A new thread created"); else System.out.println("A new thread with name " + name + " created"); } } class threadtest01 { public static void main(String args[] ) { int failed = 0 ; Thread t1 = new Thread(); if (t1 = null) System.out.println("new Thread() succeed"); else { System.out.println("new Thread() failed"); failed++; } } }@see java.lang.Thread#Thread(java.lang.ThreadGroup java.lang.Runnable java.lang.String)
Allocates a newClass Thread, int activeCount()Thread
object so that it hastarget
as its run object has the specifiedname
as its name and belongs to the thread group referred to bygroup
.If
group
isnull
and there is a security manager the group is determined by the security manager'sgetThreadGroup
method. Ifgroup
isnull
and there is not a security manager or the security manager'sgetThreadGroup
method returnsnull
the group is set to be the same ThreadGroup as the thread that is creating the new thread.If there is a security manager its
checkAccess
method is called with the ThreadGroup as its argument. This may result in a SecurityException.If the
target
argument is notnull
therun
method of thetarget
is called when this thread is started. If the target argument isnull
this thread'srun
method is called when this thread is started.The priority of the newly created thread is set equal to the priority of the thread creating it that is the currently running thread. The method
setPriority
may be used to change the priority to a new value.The newly created thread is initially marked as being a daemon thread if and only if the thread creating it is currently marked as a daemon thread. The method
setDaemon
may be used to change whether or not a thread is a daemon. @param group the thread group. @param target the object whoserun
method is called. @param name the name of the new thread. @exception SecurityException if the current thread cannot create a thread in the specified thread group. @see java.lang.Runnable#run() @see java.lang.Thread#run() @see java.lang.Thread#setDaemon(boolean) @see java.lang.Thread#setPriority(int) @see java.lang.ThreadGroup#checkAccess() @see SecurityManager#checkAccess
Returns theClass Thread, int enumerate(Thread[])currentnumber of active threads inthisthe current thread's thread group. @return thecurrentnumber of active threads inthisthe current thread's thread group.
Copies into the specified array every active thread inClass Thread, int getPriority()thisthe current thread's thread group and its subgroups. This method simply calls theenumerate
method ofthisthe current thread's thread group with the array argument.First if there is a security manager that
enumerate
method calls the security manager'scheckAccess
method with the thread group as its argument. This may result in throwing aSecurityException
. @param tarray an array of Thread objects to copy to @return the number of threads put into the array @exception SecurityException if a security manager exists and itscheckAccess
method doesn't allow the operation. @see java.lang.ThreadGroup#enumerate(java.lang.Thread[]) @see java.lang.SecurityManager#checkAccess(java.lang.ThreadGroup)
Returns this thread's priority. @return this thread'sClass Thread, void interrupt()namepriority. @see #setPriority @see java.lang.Thread#setPriority(int)
Interrupts this thread.First the checkAccess method of this thread is
calledinvokedwithwhich may causenoa SecurityExceptionargumentsto be thrown.ThisIf
@maythis thread isresultblocked inthrowinganainvocationSecurityExceptionof the wait() wait(long) or int wait(long int)} methods of the Object class or of the #join() #join(long) int) #sleep(long) or int) methods of this class then its interrupt status will be cleared and it will receive an InterruptedException interruptibl channel} then the channel will be closed the thread's interrupt status will be set and the thread will receive a java.nio.channels.ClosedByInterruptException
.If this thread is blocked in a java.nio.channels.Selector then the thread's interrupt status will be set and it will return immediately from the selection operation possibly with a non-zero value just as if the selector's wakeup method were invoked.
If none of the previous conditions hold then this thread's interrupt status will be set
exceptionthrows SecurityException if the current thread cannot modify this thread @revised 1.4 @spec JSR-51
An instance ofThreadDeath
is thrown in the victim thread when thestop
method with zero arguments in classThread
is called.An application should catch instances of this class only if it must clean up after being terminated asynchronously. If
ThreadDeath
is caught by a method it is important that it be rethrown so that the thread actually dies.The top-level error handler does not print out a message if
ThreadDeath
is never caught.The class
ThreadDeath
is specifically a subclass ofError
rather thanException
even though it is a "normal occurrence" because many applications catch all occurrences ofException
and then discard the exception. @author unascribed @version 1.12 0213 12/0203/0001 @see java.lang.Thread#stop() @since JDK1.0
A thread group represents a set of threads. In addition a thread group can also include other thread groups. The thread groups form a tree in which every thread group except the initial thread group has a parent.Class ThreadGroup, void setMaxPriority(int)A thread is allowed to access information about its own thread group but not to access information about its thread group's parent thread group or any other thread groups. @author unascribed @version 1.
51 0254 12/0203/0001 @since JDK1.0
Sets the maximum priority of the group. Threads in the thread group that already have a higher priority are not affected.First the
checkAccess
method of this thread group is called with no arguments; this may result in a security exception.
ThreadsIfinthepri
argument is less than Thread#MIN_PRIORITY or greater than Thread#MAX_PRIORITY the maximum priority of the group remains unchanged.Otherwise the priority of this ThreadGroup object is set to the smaller of the specified
the parent of this thread group.pri
and the maximum permitted priority ofthat(Ifalready have athis thread grouphigheris the system thread group which has no parent then its maximum priorityare notis simplyaffectedset topri
.) Then this method is called recursively withpri
as its argument for every thread group that belongs to this thread group. @param pri the new priority of the thread group. @exception SecurityException if the current thread cannot modify this thread group. @see #getMaxPriority @see java.lang.SecurityException @see java.lang.ThreadGroup#checkAccess() @since JDK1.0
This class providesClass ThreadLocal, Object get()ThreadLocalthread-local variables. These variables differ from their normal counterparts in that each thread that accesses one (via its get or set method) has its own independently initialized copy of the variable. ThreadLocalobjectsinstances are typically private staticvariablesfields in classes that wish to associate state with a thread (e.g. a user ID or Transaction ID).For example in the class below the private static ThreadLocal instance (serialNum) maintains a "serial number" for each thread that invokes the class's static SerialNum.get() method which returns the current thread's serial number. (A thread's serial number is assigned the first time it invokes SerialNum.get() and remains unchanged on subsequent calls.)
public class SerialNum { // The next serial number to be assigned private static int nextSerialNum = 0; private static ThreadLocal serialNum = new ThreadLocal() { protected synchronized Object initialValue() { return new Integer(nextSerialNum++); } }; public static int get() { return ((Integer) (serialNum.get())).intValue(); } }Each thread holds an implicit reference to its copy of aThreadLocalthread-local variable as long as the thread is alive and the ThreadLocalobjectinstance is accessible; after a thread goes away all of its copies ofThreadLocalthread-localvariablesinstances are subject to garbage collection (unless other references to these copies exist). @author Josh Bloch and Doug Lea @version 1.16 0219 12/0203/0001 @since 1.2
Returns the value in theClass ThreadLocal, Object initialValue()callingcurrent thread's copy of thisThreadLocalthread-local variable. Creates and initializes the copy if this is the first time the thread has called this method. @return the current thread's value of thisThreadLocalthread-local
Returns theClass ThreadLocal, void set(Object)callingcurrent thread's initial value for thisThreadLocalthread-local variable. This method will be called once per accessing thread for eachThreadLocalthread-local the first time each thread accesses the variable with the #get() or #set(Object) method. If the programmer desiresThreadLocalthread-local variables to be initialized to some value other than null ThreadLocal must be subclassed and this method overridden. Typically an anonymous inner class will be used. Typical implementations of initialValue will call an appropriate constructor and return the newly constructed object. @return the initial value for thisThreadLocalthread-local
Sets thecallingcurrent thread'sinstancecopy of thisThreadLocalthread-local variable to thegivenspecified value. This is only used to change the value from the one assigned by the initialValue method and many applications will have no need for this functionality. @param value the value to be stored in thecallingcurrent threads' copy of thisThreadLocalthread-local.
TheClass Throwable, constructor Throwable()Throwable
class is the superclass of all errors and exceptions in the Java language. Only objects that are instances of this class (orofone of its subclasses) are thrown by the Java Virtual Machine or can be thrown by the Javathrow
statement. Similarly only this class or one of its subclasses can be the argument type in acatch
clause.
Instances of two subclasses java.lang.Error and java.lang.Exception are conventionally used to indicate that exceptional situations have occurred. Typically these instances are freshly created in the context of the exceptional situation so as to include relevant information (such as stack trace data).A
By convention classthrowable contains aThrowablesnapshotandof the execution stack of itssubclasses have two constructors one thatthread at the time it wastakescreated.no arguments andIt can alsoonecontain a message string thattakesgives more information about the error. Finally it can contain aStringcause:argumentanother throwable that caused this throwable to get thrown. The cause facility is new in release 1.4. It is also known as the chained exception facility as the cause canbeitselfusedhave a cause and so on leading toproduceaan"chain"errorofmessageexceptions each caused by another.One
AreasonThrowablethat a throwable may have a cause is that the classcontainsthat throws it is built atop asnapshotlower layered abstraction and an operation on the upper layer fails due to a failure in the lower layer. It would be bad design to let the throwable thrown by the lower layer propagate outward as it is generally unrelated to the abstraction provided by the upper layer. Further doing so would tie the API of theexecutionupperstacklayer to the details of itsthread atimplementation assuming thetimeloweritlayer's exception wascreateda checked exception.It canThrowing aalso"wrappedcontainexception" (i.e. an exception containing amessagecause)string that gives more information aboutallows the upper layer to communicate theerrordetails of the failure to its caller without incurring either of these shortcomings. It preserves the flexibility to change the implementation of the upper layer without changing its API (in particular the set of exceptions thrown by its methods).A second reason that a
Herethrowable may have a cause isonethat the method that throws it must conform to a general-purpose interface that does not permit the method to throw the cause directly. For example suppose a persistent collection conforms to the Collection interface and that its persistence is implemented atop java.io. Suppose the internals ofcatchingthe put method can throw an IOException The implementation can communicate the details of the IOException to its caller while conforming to the Collection interface by wrapping the IOException in an appropriate unchecked exception:. (The specification for the persistent collection should indicate that it is capable of throwing such exceptions.)A cause can be associated with a throwable in two ways: via a constructor that takes the cause as an argument or via the #initCause(Throwable) method. New throwable classes that wish to allow causes to be associated with them should provide constructors that take a cause and delegate (perhaps indirectly) to one of the Throwable constructors that takes a cause. For example:
try {Because the initCause method is public it allows aintlowLevelOp();a[]} catch LowLevelException(le) {=throw newint[2]HighLevelException(le); // Chaining-aware constructor }[4]cause to be associated with any throwable even a "legacy throwable" whose implementation predates the addition of the exception chaining mechanism to Throwable. For example:try { lowLevelOp(); } catch LowLevelException(ArrayIndexOutOfBoundsException ele) {Systemthrow (HighLevelException) new HighLevelException().outinitCause(le); // Legacy constructor }Prior to release 1
.println4 there were many throwables that had their own non-standard exception chaining mechanisms ("ExceptionInInitializerError ClassNotFoundException java.lang.reflect.UndeclaredThrowableException java.lang.reflect.InvocationTargetException java.io.WriteAbortedException java.security.PrivilegedActionException java.awt.print.PrinterIOException and A of release 1.4 all of these throwables have been retrofitted to use the standard exception:chaining mechanism while continuing to implement their "legacy"+chainingemechanisms for compatibility.Further as of release 1.4 many general purpose Throwable classes (for example Exception RuntimeException hav been retrofitted with constructors that take a cause. This was not strictly necessary due to the existence of the initCause method but it is more convenient and expressive to delegate to a constructor that takes a cause.
By convention class
.Throwable
and its subclasses have two constructors one that takes no arguments and one that takes aString
argument that can be used to produce a detail messagegetMessageFurther those subclasses that might likely have a cause associated with them should have two more constructors one that takes aThrowable
(the cause) and one that takes aString
(the detail message) and aThrowable
(the cause);.eAlso introduced in release 1.4 is the #getStackTrace() method which allows programmatic access to the stack trace information that was previously available only in text form via the various forms of the #printStackTrace()
;}method. This information has been added to the serialized representation of this class so getStackTrace and printStackTrace will operate properly on a throwable that was obtained by deserialization. @author unascribed @author Josh Bloch (Added exception chaining and programmatic access to stack trace in 1.4.) @version 1.44 0249 12/0203/0001 @since JDK1.0
Constructs a newClass Throwable, constructor Throwable(String)Throwablethrowable withnull
as itserrordetail messagestring.Also theThe causemethodis not initialized and may subsequently be initialized by a call to #initCauseThe
#fillInStackTrace() method is calledforto initialize the stack trace data in the newlythis objectcreated throwable.
Constructs a newClass Throwable, Throwable fillInStackTrace()Throwablethrowable with the specifiederrordetail message.AlsoThethecausemethodis not initialized and may subsequently be initialized by a call to #initCauseThe
#fillInStackTrace() method is calledforto initialize the stack trace data in the newlythis objectcreated throwable. @param message theerrordetail message. Theerrordetail message is saved for later retrieval by the #getMessage() method.
Fills in the execution stack trace. This method records within thisClass Throwable, String getLocalizedMessage()Throwable
object information about the current state of the stack frames for the current thread.This method is useful when an application is re-throwing an error or exception. For example: try { a = b / c; } catch(ArithmeticThrowable e) {@return a= Double.MAX_VALUE; throw e.fillInStackTrace();reference}to@returnthisThrowable
objectinstance. @see java.lang.Throwable#printStackTrace()
Creates a localized description of thisClass Throwable, String getMessage()Throwablethrowable. Subclasses may override this method in order to produce a locale-specific message. For subclasses that do not override this method the default implementation returns the same result asgetMessage()
. @return The localized description of thisThrowablethrowable. @since JDK1.1
Returns theClass Throwable, void printStackTrace()errordetail message string of this throwableobject. @return theerrordetail message string of this Throwableobject if it wascreatedinstancewith(whichan error message string;mayorbe nullif it was created with no error message).
Prints thisClass Throwable, void printStackTrace(PrintStream)Throwablethrowable and its backtrace to the standard error stream. This method prints a stack trace for thisThrowable
object on the error output stream that is the value of the fieldSystem.err
. The first line of output contains the result of the #toString() method for this object. Remaining lines represent data previously recorded by the method #fillInStackTrace() The format of this information depends on the implementation but the following example may be regarded as typical:This example was produced by running the program:java.lang.NullPointerException at MyClass.mash(MyClass.java:9) at MyClass.crunch(MyClass.java:6) at MyClass.main(MyClass.java:3)class MyClass { public static void main(String[]The backtrace for a throwable with an initialized non-null cause should generally include the backtrace for the cause. The format of this information depends on the implementation but the following example may be regarded as typical:argvargs) { crunch(null); } static void crunch(int[] a) { mash(a); } static void mash(int[] b) { System.out.println(b[0]); } }@seeHighLevelException: MidLevelException: LowLevelException at Junk.a(Junk.java:13) at Junk.Note the presence of lines containing the characters "...". These lines indicate that the remainder of the stack trace for this exception matches the indicated number of frames from the bottom of the stack trace of the exception that was caused by this exception (the "enclosing" exception). This shorthand can greatly reduce the length of the output in the common case where a wrapped exception is thrown from same method as the "causative exception" is caught. The above example was produced by running the program:langmain(Junk.System#errjava:4) Caused by: MidLevelException: LowLevelException at Junk.c(Junk.java:23) at Junk.b(Junk.java:17) at Junk.a(Junk.java:11) ... 1 more Caused by: LowLevelException at Junk.e(Junk.java:30) at Junk.d(Junk.java:27) at Junk.c(Junk.java:21) ... 3 morepublic class Junk { public static void main(String args[]) { try { a(); } catch(HighLevelException e) { e.printStackTrace(); } } static void a() throws HighLevelException { try { b(); } catch(MidLevelException e) { throw new HighLevelException(e); } } static void b() throws MidLevelException { c(); } static void c() throws MidLevelException { try { d(); } catch(LowLevelException e) { throw new MidLevelException(e); } } static void d() throws LowLevelException { e(); } static void e() throws LowLevelException { throw new LowLevelException(); } } class HighLevelException extends Exception { HighLevelException(Throwable cause) { super(cause); } } class MidLevelException extends Exception { MidLevelException(Throwable cause) { super(cause); } } class LowLevelException extends Exception { }
Prints thisClass Throwable, void printStackTrace(PrintWriter)Throwablethrowable and its backtrace to the specified print stream. @param sPrintStream
to use for output
Prints thisClass Throwable, String toString()Throwablethrowable and its backtrace to the specified print writer. @param sPrintWriter
to use for output @since JDK1.1
Returns a short description of this throwableobject. If thisThrowable
object was created withana non-nullerrordetail message string then the result is the concatenation of three strings:If this
- The name of the actual class of this object
- ": " (a colon and a space)
- The result of the #getMessage method for this object
Throwable
object was created withnoa nullerrordetail message string then the name of the actual class of this object is returned. @return a string representation of thisThrowablethrowable.
Thrown when an unknown but serious exception has occurred in the Java Virtual Machine. @author unascribed @version 1.10 0211 12/0203/0001 @since JDK1.0
Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declarednative
. @author unascribed @version 1.18 0219 12/0203/0001 @see java.lang.Runtime @since JDK1.0
Thrown to indicate that the requested operation is not supported. @author Josh Bloch @version 1.12 0213 12/0203/0001 @since 1.2
Thrown when the "verifier" detects that a class file though well formed contains some sort of internal inconsistency or security problem. @author unascribed @version 1.10 0211 12/0203/0001 @since JDK1.0
Thrown to indicate that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating. @author Frank Yellin @version 1.11 0212 12/0203/0001 @since JDK1.0
The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing theprimitiveJavatypekeyword void. @author unascribed @version 1.8100212/0203/0001 @since JDK1.1