java.lang
Class Character
- java.lang.Object
-
- java.lang.Character
-
public final class Character extends Object
-
-
Field Summary
Fields Modifier and Type Field and Description static int
MAX_RADIX
The maximum radix used for conversions between characters and integers.static char
MAX_VALUE
The maximumCharacter
value.static int
MIN_RADIX
The minimum radix used for conversions between characters and integers.static char
MIN_VALUE
The minimumCharacter
value.
-
Constructor Summary
Constructors Constructor and Description Character(char value)
Constructs a newCharacter
with the specified primitive char value.
-
Method Summary
Methods Modifier and Type Method and Description char
charValue()
Gets the primitive value of this character.static int
digit(char c, int radix)
Convenience method to determine the value of the specified characterc
in the supplied radix.boolean
equals(Object object)
Compares this object with the specified object and indicates if they are equal.int
hashCode()
Returns an integer hash code for this character.static boolean
isDigit(char c)
Indicates whether the specified character is a digit.static boolean
isLowerCase(char c)
Indicates whether the specified character is a lower case letter.static boolean
isUpperCase(char c)
Indicates whether the specified character is an upper case letter.static char
toLowerCase(char c)
Returns the lower case equivalent for the specified character if the character is an upper case letter.String
toString()
Converts this character to its string representation.static char
toUpperCase(char c)
Returns the upper case equivalent for the specified character if the character is a lower case letter.static Character
valueOf(char c)
Returns aCharacter
instance for thechar
value passed.
-
-
-
Field Detail
-
MIN_VALUE
public static final char MIN_VALUE
The minimumCharacter
value.- See Also:
- Constant Field Values
-
MAX_VALUE
public static final char MAX_VALUE
The maximumCharacter
value.- See Also:
- Constant Field Values
-
MIN_RADIX
public static final int MIN_RADIX
The minimum radix used for conversions between characters and integers.- See Also:
- Constant Field Values
-
MAX_RADIX
public static final int MAX_RADIX
The maximum radix used for conversions between characters and integers.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Character
public Character(char value)
Constructs a newCharacter
with the specified primitive char value.- Parameters:
value
- the primitive char value to store in the new instance.
-
-
Method Detail
-
charValue
public char charValue()
Gets the primitive value of this character.- Returns:
- this object's primitive value.
-
valueOf
public static Character valueOf(char c)
Returns aCharacter
instance for thechar
value passed. For ASCII/Latin-1 characters (and generally all characters with a Unicode value up to 512), this method should be used instead of the constructor, as it maintains a cache of correspondingCharacter
instances.- Parameters:
c
- the char value for which to get aCharacter
instance.- Returns:
- the
Character
instance forc
. - Since:
- 1.5
-
equals
public boolean equals(Object object)
Compares this object with the specified object and indicates if they are equal. In order to be equal,object
must be an instance ofCharacter
and have the same char value as this object.- Overrides:
equals
in classObject
- Parameters:
object
- the object to compare this double with.- Returns:
true
if the specified object is equal to thisCharacter
;false
otherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()
Returns an integer hash code for this character.- Overrides:
hashCode
in classObject
- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
toString
public String toString()
Converts this character to its string representation.
-
digit
public static int digit(char c, int radix)
Convenience method to determine the value of the specified characterc
in the supplied radix. The value ofradix
must be between MIN_RADIX and MAX_RADIX.
-
isDigit
public static boolean isDigit(char c)
Indicates whether the specified character is a digit.- Parameters:
c
- the character to check.- Returns:
true
ifc
is a digit;false
otherwise.
-
isLowerCase
public static boolean isLowerCase(char c)
Indicates whether the specified character is a lower case letter.- Parameters:
c
- the character to check.- Returns:
true
ifc
is a lower case letter;false
otherwise.
-
isUpperCase
public static boolean isUpperCase(char c)
Indicates whether the specified character is an upper case letter.- Parameters:
c
- the character to check.- Returns:
true
ifc
is a upper case letter;false
otherwise.
-
toLowerCase
public static char toLowerCase(char c)
Returns the lower case equivalent for the specified character if the character is an upper case letter. Otherwise, the specified character is returned unchanged.- Parameters:
c
- the character- Returns:
- if
c
is an upper case character then its lower case counterpart, otherwise justc
.
-
toUpperCase
public static char toUpperCase(char c)
Returns the upper case equivalent for the specified character if the character is a lower case letter. Otherwise, the specified character is returned unchanged.- Parameters:
c
- the character to convert.- Returns:
- if
c
is a lower case character then its upper case counterpart, otherwise justc
.
-
-