UNIDAD 1: JAVA ELEMENTOS BASICOS
TEMA 5: JAVA CLASES ESPECIALES
En java como lenguaje de programacion orientado a objetos existen aparte de la clase String vista en el tema anterior cuatro clases especiales descendientes de la clase numbers que contienen una serie de metodos que facilitan la interaccion con los usuarios de nuestras aplicaciones en captura y despliegue de datos numericos.
Sin embargo su caracteristica mas importante a tomar en cuenta es que objetos numericos derivados de estaS clase no pueden entrar a operaciones DIRECTAMENTE ni recibir el resultado de operaciones.
Class Integer
public final class java.lang.**Integer **extends java.lang.**Number**
{
// Fields
public final static int **MAX_VALUE**;
public final static int **MIN_VALUE**;
// Constructors
public **Integer**(int value);
public **Integer**(String s);
// Methods
public double **doubleValue**();
public boolean **equals**(Object obj);
public float **floatValue**();
public static Integer **getInteger**(String nm);
public static Integer **getInteger**(String nm, int val);
public static Integer **getInteger**(String nm, Integer val);
public int **hashCode**();
public int **intValue**();
public long **longValue**();
public static int **parseInt**(String s);
public static int **parseInt**(String s, int radix);
public static String **toBinaryString**(int i);
public static String **toHexString**(int i);
public static String **toOctalString**(int i);
public String **toString**();
public static String **toString**(int i);
public static String **toString**(int i, int radix);
public static Integer **valueOf**(String s);
public static Integer **valueOf**(String s, int radix);
}
Esta clase convierte un dato de tipo int a un objeto.
Este objeto contiene un solo campo de tipo int.
Pero tambien el objeto contiene una serie de metodos para convertir un valor int a una String y tambien para convertir una String a int.
Ademas de otros metodos de igual utilidad.
Class Double
public final class java.lang.Double extends java.lang.Number
{
// Fields
public final static double **MAX_VALUE**;
public final static double **MIN_VALUE**;
public final static double **NaN**;
public final static double **NEGATIVE_INFINITY**;
public final static double **POSITIVE_INFINITY**;
// Constructors
public **Double**(double value);
public **Double**(String s);
// Methods
public static long **doubleToLongBits**(double value);
public double **doubleValue**();
public boolean **equals**(Object obj);
public float **floatValue**();
public int **hashCode**();
public int **intValue**();
public boolean **isInfinite**();
public static boolean **isInfinite**(double v);
public boolean **isNaN**();
public static boolean **isNaN**(double v);
public static double **longBitsToDouble**(long bits);
public long **longValue**();
public String **toString**();
public static String **toString**(double d);
public static Double **valueOf**(String s);
}
Class Float
public final class java.lang.**Float **extends java.lang.**Number**
{
// Fields
public final static float **MAX_VALUE**;
public final static float **MIN_VALUE**;
public final static float **NaN**;
public final static float **NEGATIVE_INFINITY**;
public final static float **POSITIVE_INFINITY**;
// Constructors
public **Float**(double value);
public **Float**(float value);
public **Float**(String s);
// Methods
public double **doubleValue**();
public boolean **equals**(Object obj);
public static int **floatToIntBits**(float value);
public float **floatValue**();
public int **hashCode**();
public static float **intBitsToFloat**(int bits);
public int **intValue**();
public boolean **isInfinite**();
public static boolean **isInfinite**(float v);
public boolean **isNaN**();
public static boolean **isNaN**(float v);
public long **longValue**();
public String **toString**();
public static String **toString**(float f);
public static Float **valueOf**(String s);
}
Constructores:
String() Constructs a new empty String.
String(String) Constructs a new String that is a copy of the specified String.
String(char[]) Constructs a new String whose initial value is the specified array of characters.
String(char[], int, int) Constructs a new String whose initial value is the specified sub array of characters.
String(byte[], int, int, int) Constructs a new String whose initial value is the specified sub array of bytes.
String(byte[], int) Constructs a new String whose value is the specified array of bytes.
String(StringBuffer) Construct a new string whose value is the current contents of the given string buffer
METODOS:**
charAt(int) Returns the character at the specified index.compareTo(String) Compares this String to another specified String.concat(String) Concatenates the specified string to the end of this String.copyValueOf(char[], int, int) Returns a String that is equivalent to the specified character array.copyValueOf(char[]) Returns a String that is equivalent to the specified character array.endsWith(String) Determines whether the String ends with some suffix.equals(Object) Compares this String to the specified object.equalsIgnoreCase(String) Compares this String to another object.getBytes(int, int, byte[], int) Copies characters from this String into the specified byte array.getChars(int, int, char[], int) Copies characters from this String into the specified character array.hashCode() Returns a hashcode for this String.indexOf(int) Returns the index within this String of the first occurrence of the specified character.indexOf(int, int) Returns the index within this String of the first occurrence of the specified character, starting the search at fromIndex.indexOf(String) Returns the index within this String of the first occurrence of the specified substring.indexOf(String, int) Returns the index within this String of the first occurrence of the specified substring.intern() Returns a String that is equal to this String but which is guaranteed to be from the unique String pool.lastIndexOf(int) Returns the index within this String of the last occurrence of the specified character.lastIndexOf(int, int) Returns the index within this String of the last occurrence of the specified character.lastIndexOf(String) Returns the index within this String of the last occurrence of the specified substring.
lastIndexOf(String, int) Returns the index within this String of the last occurrence of the specified substring.length() Returns the length of the String.regionMatches(int, String, int, int) Determines whether a region of this String matches the specified region of the specified String.regionMatches(boolean, int, String, int, int) Determines whether a region of this String matches the specified region of the specified String.replace(char, char) Converts this String by replacing all occurences of oldChar with newChar.startsWith(String, int) Determines whether this String starts with some prefix.startsWith(String) Determines whether this String starts with some prefix.substring(int) Returns the substring of this String.substring(int, int) Returns the substring of a String.toCharArray() Converts this String to a character array.toLowerCase() Converts all of the characters in this String to lower case.toString() Converts this String to a String.toUpperCase() Converts all of the characters in this String to upper case.trim() Trims leading and trailing whitespace from this String.valueOf(Object) Returns a String that represents the String value of the object.valueOf(char[]) Returns a String that is equivalent to the specified character array.valueOf(char[], int, int) Returns a String that is equivalent to the specified character array.valueOf(boolean) Returns a String object that represents the state of the specified boolean.valueOf(char) Returns a String object that contains a single charactervalueOf(int) Returns a String object that represents the value of the specified integer.valueOf(long) Returns a String object that represents the value of the specified long.valueOf(float) Returns a String object that represents the value of the specified float.valueOf(double) Returns a String object that represents the value of the specified double.