Klaseis java

Συζητήσεις για την Java

Συντονιστές: WebDev Moderators, Super-Moderators

Απάντηση
JOHNYS20
Δημοσιεύσεις: 28
Εγγραφή: 29 Νοέμ 2010 18:08

Klaseis java

Δημοσίευση από JOHNYS20 » 17 Φεβ 2011 23:48

Μετατροπή των immutable (αμετάβλητων) κλάσεων (Integer, Float, Double, Byte,
Long, Boolean, Short) της γλώσσας προγραμματισμού java σε κανονικές κλάσεις. -
Απαιτεί την τροποποίηση του κώδικα της γλώσσας προγραμματισμού Java.
XEREI KANEIS POY THA VRO TIS IMMUTABLE KLASEIS TON Integer, Float, Double, Byte,Long, Boolean, Short TIS JAVA;

pimpogio
Δημοσιεύσεις: 1080
Εγγραφή: 28 Δεκ 2010 14:08

Klaseis java

Δημοσίευση από pimpogio » 17 Φεβ 2011 23:52

στο java.lang εψαξες ?

Αλλα ηδη ειναι κανονικες classes οποτε ειναι ακυρο το ερωτημα ...

Δες και μονος σου..

Κώδικας: Επιλογή όλων

/*
 * %W% %E%
 *
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package java.lang;

import java.util.Properties;

/**
 * The <code>Integer</code> class wraps a value of the primitive type
 * <code>int</code> in an object. An object of type
 * <code>Integer</code> contains a single field whose type is
 * <code>int</code>.
 *
 *  <p>
 * 
 * In addition, this class provides several methods for converting an
 * <code>int</code> to a <code>String</code> and a <code>String</code>
 * to an <code>int</code>, as well as other constants and methods
 * useful when dealing with an <code>int</code>.
 *
 * <p>Implementation note&#58; The implementations of the "bit twiddling"
 * methods &#40;such as &#123;@link #highestOneBit&#40;int&#41; highestOneBit&#125; and
 * &#123;@link #numberOfTrailingZeros&#40;int&#41; numberOfTrailingZeros&#125;&#41; are
 * based on material from Henry S. Warren, Jr.'s <i>Hacker's
 * Delight</i>, &#40;Addison Wesley, 2002&#41;.
 *
 * @author  Lee Boynton
 * @author  Arthur van Hoff
 * @author  Josh Bloch
 * @version %I%, %G%
 * @since JDK1.0
 */
public final class Integer extends Number implements Comparable<Integer> &#123;
    /**
     * A constant holding the minimum value an <code>int</code> can
     * have, -2<sup>31</sup>.
     */
    public static final int   MIN_VALUE = 0x80000000;

    /**
     * A constant holding the maximum value an <code>int</code> can
     * have, 2<sup>31</sup>-1.
     */
    public static final int   MAX_VALUE = 0x7fffffff;

    /**
     * The <code>Class</code> instance representing the primitive type
     * <code>int</code>.
     *
     * @since   JDK1.1
     */
    public static final Class<Integer>	TYPE = &#40;Class<Integer>&#41; Class.getPrimitiveClass&#40;"int"&#41;;

    /**
     * All possible chars for representing a number as a String
     */
    final static char&#91;&#93; digits = &#123;
	'0' , '1' , '2' , '3' , '4' , '5' ,
	'6' , '7' , '8' , '9' , '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'
    &#125;;

    /**
     * Returns a string representation of the first argument in the
     * radix specified by the second argument.
     * <p>
     * If the radix is smaller than <code>Character.MIN_RADIX</code>
     * or larger than <code>Character.MAX_RADIX</code>, then the radix
     * <code>10</code> is used instead.
     * <p>
     * If the first argument is negative, the first element of the
     * result is the ASCII minus character <code>'-'</code>
     * &#40;<code>'\u002D'</code>&#41;. If the first argument is not
     * negative, no sign character appears in the result.
     * <p>
     * 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 <code>'0'</code>
     * &#40;<code>'\u0030'</code>&#41;; otherwise, the first character of
     * the representation of the magnitude will not be the zero
     * character.  The following ASCII characters are used as digits&#58; 
     * <blockquote><pre>
     *   0123456789abcdefghijklmnopqrstuvwxyz
     * </pre></blockquote>
     * These are <code>'\u0030'</code> through
     * <code>'\u0039'</code> and <code>'\u0061'</code> through
     * <code>'\u007A'</code>. If <code>radix</code> is
     * <var>N</var>, then the first <var>N</var> of these characters
     * are used as radix-<var>N</var> digits in the order shown. Thus,
     * the digits for hexadecimal &#40;radix 16&#41; are
     * <code>0123456789abcdef</code>. If uppercase letters are
     * desired, the &#123;@link java.lang.String#toUpperCase&#40;&#41;&#125; method may
     * be called on the result&#58;
     * <blockquote><pre>
     * Integer.toString&#40;n, 16&#41;.toUpperCase&#40;&#41;
     * </pre></blockquote>
     *
     * @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_RADIX
     */
    public static String toString&#40;int i, int radix&#41; &#123;

        if &#40;radix < Character.MIN_RADIX || radix > Character.MAX_RADIX&#41;
	    radix = 10;

	/* Use the faster version */
	if &#40;radix == 10&#41; &#123;
	    return toString&#40;i&#41;;
	&#125;

	char buf&#91;&#93; = new char&#91;33&#93;;
	boolean negative = &#40;i < 0&#41;;
	int charPos = 32;

	if &#40;!negative&#41; &#123;
	    i = -i;
	&#125;

	while &#40;i <= -radix&#41; &#123;
	    buf&#91;charPos--&#93; = digits&#91;-&#40;i % radix&#41;&#93;;
	    i = i / radix;
	&#125;
	buf&#91;charPos&#93; = digits&#91;-i&#93;;

	if &#40;negative&#41; &#123;
	    buf&#91;--charPos&#93; = '-';
	&#125;

	return new String&#40;buf, charPos, &#40;33 - charPos&#41;&#41;;
    &#125;

    /**
     * Returns a string representation of the integer argument as an
     * unsigned integer in base&nbsp;16.
     * <p>
     * The unsigned integer value is the argument plus 2<sup>32</sup>
     * if the argument is negative; otherwise, it is equal to the
     * argument.  This value is converted to a string of ASCII digits
     * in hexadecimal &#40;base&nbsp;16&#41; with no extra leading
     * <code>0</code>s. If the unsigned magnitude is zero, it is
     * represented by a single zero character <code>'0'</code>
     * &#40;<code>'\u0030'</code>&#41;; 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&#58;
     * <blockquote><pre>
     * 0123456789abcdef
     * </pre></blockquote>
     * These are the characters <code>'\u0030'</code> through
     * <code>'\u0039'</code> and <code>'\u0061'</code> through
     * <code>'\u0066'</code>. If uppercase letters are
     * desired, the &#123;@link java.lang.String#toUpperCase&#40;&#41;&#125; method may
     * be called on the result&#58;
     * <blockquote><pre>
     * Integer.toHexString&#40;n&#41;.toUpperCase&#40;&#41;
     * </pre></blockquote>
     *
     * @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 &#40;base&nbsp;16&#41;.
     * @since   JDK1.0.2
     */
    public static String toHexString&#40;int i&#41; &#123;
	return toUnsignedString&#40;i, 4&#41;;
    &#125;

    /**
     * Returns a string representation of the integer argument as an
     * unsigned integer in base&nbsp;8.
     * <p>
     * The unsigned integer value is the argument plus 2<sup>32</sup>
     * if the argument is negative; otherwise, it is equal to the
     * argument.  This value is converted to a string of ASCII digits
     * in octal &#40;base&nbsp;8&#41; with no extra leading <code>0</code>s.
     * <p>
     * If the unsigned magnitude is zero, it is represented by a
     * single zero character <code>'0'</code>
     * &#40;<code>'\u0030'</code>&#41;; 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&#58;
     * <blockquote><pre>
     * 01234567
     * </pre></blockquote>
     * These are the characters <code>'\u0030'</code> through
     * <code>'\u0037'</code>.
     *
     * @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 &#40;base&nbsp;8&#41;.
     * @since   JDK1.0.2
     */
    public static String toOctalString&#40;int i&#41; &#123;
	return toUnsignedString&#40;i, 3&#41;;
    &#125;

    /**
     * Returns a string representation of the integer argument as an
     * unsigned integer in base&nbsp;2.
     * <p>
     * The unsigned integer value is the argument plus 2<sup>32</sup>
     * if the argument is negative; otherwise it is equal to the
     * argument.  This value is converted to a string of ASCII digits
     * in binary &#40;base&nbsp;2&#41; with no extra leading <code>0</code>s.
     * If the unsigned magnitude is zero, it is represented by a
     * single zero character <code>'0'</code>
     * &#40;<code>'\u0030'</code>&#41;; otherwise, the first character of
     * the representation of the unsigned magnitude will not be the
     * zero character. The characters <code>'0'</code>
     * &#40;<code>'\u0030'</code>&#41; and <code>'1'</code>
     * &#40;<code>'\u0031'</code>&#41; 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 &#40;base&nbsp;2&#41;.
     * @since   JDK1.0.2
     */
    public static String toBinaryString&#40;int i&#41; &#123;
	return toUnsignedString&#40;i, 1&#41;;
    &#125;

    /**
     * Convert the integer to an unsigned number.
     */
    private static String toUnsignedString&#40;int i, int shift&#41; &#123;
	char&#91;&#93; buf = new char&#91;32&#93;;
	int charPos = 32;
	int radix = 1 << shift;
	int mask = radix - 1;
	do &#123;
	    buf&#91;--charPos&#93; = digits&#91;i & mask&#93;;
	    i >>>= shift;
	&#125; while &#40;i != 0&#41;;

	return new String&#40;buf, charPos, &#40;32 - charPos&#41;&#41;;
    &#125;


    final static char &#91;&#93; DigitTens = &#123;
	'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
	'1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
	'2', '2', '2', '2', '2', '2', '2', '2', '2', '2',
	'3', '3', '3', '3', '3', '3', '3', '3', '3', '3',
	'4', '4', '4', '4', '4', '4', '4', '4', '4', '4',
	'5', '5', '5', '5', '5', '5', '5', '5', '5', '5',
	'6', '6', '6', '6', '6', '6', '6', '6', '6', '6',
	'7', '7', '7', '7', '7', '7', '7', '7', '7', '7',
	'8', '8', '8', '8', '8', '8', '8', '8', '8', '8',
	'9', '9', '9', '9', '9', '9', '9', '9', '9', '9',
	&#125; ; 

    final static char &#91;&#93; DigitOnes = &#123; 
	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
	'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
	&#125; ;

	// I use the "invariant division by multiplication" trick to
	// accelerate Integer.toString.  In particular we want to
	// avoid division by 10.
	//
	// The "trick" has roughly the same performance characteristics
	// as the "classic" Integer.toString code on a non-JIT VM.
	// The trick avoids .rem and .div calls but has a longer code
	// path and is thus dominated by dispatch overhead.  In the
	// JIT case the dispatch overhead doesn't exist and the
	// "trick" is considerably faster than the classic code.
	//
	// TODO-FIXME&#58; convert &#40;x * 52429&#41; into the equiv shift-add
	// sequence.
	//
	// RE&#58;  Division by Invariant Integers using Multiplication
	//      T Gralund, P Montgomery
	//      ACM PLDI 1994
	//

    /**
     * Returns a <code>String</code> 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 &#123;@link
     * #toString&#40;int, int&#41;&#125; method.
     *
     * @param   i   an integer to be converted.
     * @return  a string representation of the argument in base&nbsp;10.
     */
    public static String toString&#40;int i&#41; &#123;
        if &#40;i == Integer.MIN_VALUE&#41;
            return "-2147483648";
        int size = &#40;i < 0&#41; ? stringSize&#40;-i&#41; + 1 &#58; stringSize&#40;i&#41;;
        char&#91;&#93; buf = new char&#91;size&#93;;
        getChars&#40;i, size, buf&#41;;
        return new String&#40;0, size, buf&#41;;
    &#125;

    /**
     * Places characters representing the integer i into the
     * character array buf. The characters are placed into
     * the buffer backwards starting with the least significant
     * digit at the specified index &#40;exclusive&#41;, and working
     * backwards from there.
     *
     * Will fail if i == Integer.MIN_VALUE
     */
    static void getChars&#40;int i, int index, char&#91;&#93; buf&#41; &#123;
        int q, r;
        int charPos = index;
        char sign = 0;

        if &#40;i < 0&#41; &#123; 
            sign = '-';
            i = -i;
        &#125;

        // Generate two digits per iteration
        while &#40;i >= 65536&#41; &#123;
            q = i / 100;
        // really&#58; r = i - &#40;q * 100&#41;;
            r = i - &#40;&#40;q << 6&#41; + &#40;q << 5&#41; + &#40;q << 2&#41;&#41;;
            i = q;
            buf &#91;--charPos&#93; = DigitOnes&#91;r&#93;;
            buf &#91;--charPos&#93; = DigitTens&#91;r&#93;;
        &#125;

        // Fall thru to fast mode for smaller numbers
        // assert&#40;i <= 65536, i&#41;;
        for &#40;;;&#41; &#123; 
            q = &#40;i * 52429&#41; >>> &#40;16+3&#41;;
            r = i - &#40;&#40;q << 3&#41; + &#40;q << 1&#41;&#41;;  // r = i-&#40;q*10&#41; ...
            buf &#91;--charPos&#93; = digits &#91;r&#93;;
            i = q;
            if &#40;i == 0&#41; break;
        &#125;
        if &#40;sign != 0&#41; &#123;
            buf &#91;--charPos&#93; = sign;
        &#125;
    &#125;

    final static int &#91;&#93; sizeTable = &#123; 9, 99, 999, 9999, 99999, 999999, 9999999,
                                      99999999, 999999999, Integer.MAX_VALUE &#125;;

    // Requires positive x
    static int stringSize&#40;int x&#41; &#123;
        for &#40;int i=0; ; i++&#41;
            if &#40;x <= sizeTable&#91;i&#93;&#41;
                return i+1;
    &#125;
    
    /**
     * 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 &#40;as determined by 
     * whether &#123;@link java.lang.Character#digit&#40;char, int&#41;&#125; returns a 
     * nonnegative value&#41;, except that the first character may be an 
     * ASCII minus sign <code>'-'</code> &#40;<code>'\u002D'</code>&#41; to 
     * indicate a negative value. The resulting integer value is returned. 
     * <p>
     * An exception of type <code>NumberFormatException</code> is
     * thrown if any of the following situations occurs&#58;
     * <ul>
     * <li>The first argument is <code>null</code> or is a string of
     * length zero.
     * <li>The radix is either smaller than 
     * &#123;@link java.lang.Character#MIN_RADIX&#125; or
     * larger than &#123;@link java.lang.Character#MAX_RADIX&#125;. 
     * <li>Any character of the string is not a digit of the specified
     * radix, except that the first character may be a minus sign
     * <code>'-'</code> &#40;<code>'\u002D'</code>&#41; provided that the
     * string is longer than length 1.
     * <li>The value represented by the string is not a value of type
     * <code>int</code>. 
     * </ul><p>
     * Examples&#58;
     * <blockquote><pre>
     * parseInt&#40;"0", 10&#41; returns 0
     * parseInt&#40;"473", 10&#41; returns 473
     * parseInt&#40;"-0", 10&#41; returns 0
     * parseInt&#40;"-FF", 16&#41; returns -255
     * parseInt&#40;"1100110", 2&#41; returns 102
     * parseInt&#40;"2147483647", 10&#41; returns 2147483647
     * parseInt&#40;"-2147483648", 10&#41; returns -2147483648
     * parseInt&#40;"2147483648", 10&#41; throws a NumberFormatException
     * parseInt&#40;"99", 8&#41; throws a NumberFormatException
     * parseInt&#40;"Kona", 10&#41; throws a NumberFormatException
     * parseInt&#40;"Kona", 27&#41; returns 411787
     * </pre></blockquote>
     *
     * @param      s   the <code>String</code> containing the integer 
     * 			representation to be parsed
     * @param      radix   the radix to be used while parsing <code>s</code>.
     * @return     the integer represented by the string argument in the
     *             specified radix.
     * @exception  NumberFormatException if the <code>String</code>
     * 		   does not contain a parsable <code>int</code>.
     */
    public static int parseInt&#40;String s, int radix&#41;
		throws NumberFormatException
    &#123;
        if &#40;s == null&#41; &#123;
            throw new NumberFormatException&#40;"null"&#41;;
        &#125;

	if &#40;radix < Character.MIN_RADIX&#41; &#123;
	    throw new NumberFormatException&#40;"radix " + radix +
					    " less than Character.MIN_RADIX"&#41;;
	&#125;

	if &#40;radix > Character.MAX_RADIX&#41; &#123;
	    throw new NumberFormatException&#40;"radix " + radix +
					    " greater than Character.MAX_RADIX"&#41;;
	&#125;

	int result = 0;
	boolean negative = false;
	int i = 0, max = s.length&#40;&#41;;
	int limit;
	int multmin;
	int digit;

	if &#40;max > 0&#41; &#123;
	    if &#40;s.charAt&#40;0&#41; == '-'&#41; &#123;
		negative = true;
		limit = Integer.MIN_VALUE;
		i++;
	    &#125; else &#123;
		limit = -Integer.MAX_VALUE;
	    &#125;
	    multmin = limit / radix;
	    if &#40;i < max&#41; &#123;
		digit = Character.digit&#40;s.charAt&#40;i++&#41;,radix&#41;;
		if &#40;digit < 0&#41; &#123;
		    throw NumberFormatException.forInputString&#40;s&#41;;
		&#125; else &#123;
		    result = -digit;
		&#125;
	    &#125;
	    while &#40;i < max&#41; &#123;
		// Accumulating negatively avoids surprises near MAX_VALUE
		digit = Character.digit&#40;s.charAt&#40;i++&#41;,radix&#41;;
		if &#40;digit < 0&#41; &#123;
		    throw NumberFormatException.forInputString&#40;s&#41;;
		&#125;
		if &#40;result < multmin&#41; &#123;
		    throw NumberFormatException.forInputString&#40;s&#41;;
		&#125;
		result *= radix;
		if &#40;result < limit + digit&#41; &#123;
		    throw NumberFormatException.forInputString&#40;s&#41;;
		&#125;
		result -= digit;
	    &#125;
	&#125; else &#123;
	    throw NumberFormatException.forInputString&#40;s&#41;;
	&#125;
	if &#40;negative&#41; &#123;
	    if &#40;i > 1&#41; &#123;
		return result;
	    &#125; else &#123;	/* Only got "-" */
		throw NumberFormatException.forInputString&#40;s&#41;;
	    &#125;
	&#125; else &#123;
	    return -result;
	&#125;
    &#125;

    /**
     * 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 sign <code>'-'</code> 
     * &#40;<code>'\u002D'</code>&#41; 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 
     * &#123;@link #parseInt&#40;java.lang.String, int&#41;&#125; method.
     *
     * @param s	   a <code>String</code> containing the <code>int</code>
     *             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.
     */
    public static int parseInt&#40;String s&#41; throws NumberFormatException &#123;
	return parseInt&#40;s,10&#41;;
    &#125;

    /**
     * Returns an <code>Integer</code> object holding the value
     * extracted from the specified <code>String</code> 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 &#123;@link #parseInt&#40;java.lang.String, int&#41;&#125;
     * method. The result is an <code>Integer</code> object that
     * represents the integer value specified by the string.
     * <p>
     * In other words, this method returns an <code>Integer</code>
     * object equal to the value of&#58;
     *
     * <blockquote><code>
     * new Integer&#40;Integer.parseInt&#40;s, radix&#41;&#41;  
     * </code></blockquote>
     *
     * @param      s   the string to be parsed.
     * @param      radix the radix to be used in interpreting <code>s</code>
     * @return     an <code>Integer</code> object holding the value
     *             represented by the string argument in the specified
     *             radix.
     * @exception NumberFormatException if the <code>String</code>
     * 		  does not contain a parsable <code>int</code>.
     */
    public static Integer valueOf&#40;String s, int radix&#41; throws NumberFormatException &#123;
	return Integer.valueOf&#40;parseInt&#40;s,radix&#41;&#41;;
    &#125;

    /**
     * Returns an <code>Integer</code> object holding the
     * value of the specified <code>String</code>. The argument is
     * interpreted as representing a signed decimal integer, exactly
     * as if the argument were given to the &#123;@link
     * #parseInt&#40;java.lang.String&#41;&#125; method. The result is an
     * <code>Integer</code> object that represents the integer value
     * specified by the string.
     * <p>
     * In other words, this method returns an <code>Integer</code>
     * object equal to the value of&#58;
     *
     * <blockquote><code>
     * new Integer&#40;Integer.parseInt&#40;s&#41;&#41;
     * </code></blockquote>
     *
     * @param      s   the string to be parsed.
     * @return     an <code>Integer</code> object holding the value
     *             represented by the string argument.
     * @exception  NumberFormatException  if the string cannot be parsed 
     *             as an integer.
     */
    public static Integer valueOf&#40;String s&#41; throws NumberFormatException &#123;
	return Integer.valueOf&#40;parseInt&#40;s, 10&#41;&#41;;
    &#125;

    /**
     * Cache to support the object identity semantics of autoboxing for values between 
     * -128 and 127 &#40;inclusive&#41; as required by JLS.
     *
     * The cache is initialized on first usage. During VM initialization the
     * getAndRemoveCacheProperties method may be used to get and remove any system
     * properites that configure the cache size. At this time, the size of the
     * cache may be controlled by the vm option -XX&#58;AutoBoxCacheMax=<size>.
     */

    // value of java.lang.Integer.IntegerCache.high property &#40;obtained during VM init&#41;
    private static String integerCacheHighPropValue;

    static void getAndRemoveCacheProperties&#40;&#41; &#123;
        if &#40;!sun.misc.VM.isBooted&#40;&#41;&#41; &#123;
            Properties props = System.getProperties&#40;&#41;;
            integerCacheHighPropValue =
                &#40;String&#41;props.remove&#40;"java.lang.Integer.IntegerCache.high"&#41;;
            if &#40;integerCacheHighPropValue != null&#41;
                System.setProperties&#40;props&#41;;  // remove from system props
        &#125;
    &#125;

    private static class IntegerCache &#123;
        static final int high;
        static final Integer cache&#91;&#93;;

        static &#123;
            final int low = -128;

            // high value may be configured by property
            int h = 127;
            if &#40;integerCacheHighPropValue != null&#41; &#123;
                // Use Long.decode here to avoid invoking methods that
                // require Integer's autoboxing cache to be initialized
                int i = Long.decode&#40;integerCacheHighPropValue&#41;.intValue&#40;&#41;;
                i = Math.max&#40;i, 127&#41;;
                // Maximum array size is Integer.MAX_VALUE
                h = Math.min&#40;i, Integer.MAX_VALUE - -low&#41;;
            &#125;
            high = h;

            cache = new Integer&#91;&#40;high - low&#41; + 1&#93;;
            int j = low;
            for&#40;int k = 0; k < cache.length; k++&#41;
                cache&#91;k&#93; = new Integer&#40;j++&#41;;
        &#125;

        private IntegerCache&#40;&#41; &#123;&#125;
    &#125;

    /**
     * Returns a <tt>Integer</tt> instance representing the specified
     * <tt>int</tt> value.
     * If a new <tt>Integer</tt> instance is not required, this method
     * should generally be used in preference to the constructor
     * &#123;@link #Integer&#40;int&#41;&#125;, as this method is likely to yield
     * significantly better space and time performance by caching
     * frequently requested values.
     *
     * @param  i an <code>int</code> value.
     * @return a <tt>Integer</tt> instance representing <tt>i</tt>.
     * @since  1.5
     */
    public static Integer valueOf&#40;int i&#41; &#123;
        if&#40;i >= -128 && i <= IntegerCache.high&#41;
            return IntegerCache.cache&#91;i + 128&#93;;
        else
            return new Integer&#40;i&#41;;
    &#125;

    /**
     * The value of the <code>Integer</code>.
     *
     * @serial
     */
    private final int value;

    /**
     * Constructs a newly allocated <code>Integer</code> object that
     * represents the specified <code>int</code> value.
     *
     * @param   value   the value to be represented by the 
     *			<code>Integer</code> object.
     */
    public Integer&#40;int value&#41; &#123;
	this.value = value;
    &#125;

    /**
     * Constructs a newly allocated <code>Integer</code> object that
     * represents the <code>int</code> value indicated by the
     * <code>String</code> parameter. The string is converted to an
     * <code>int</code> value in exactly the manner used by the
     * <code>parseInt</code> method for radix 10.
     *
     * @param      s   the <code>String</code> to be converted to an
     *                 <code>Integer</code>.
     * @exception  NumberFormatException  if the <code>String</code> does not
     *               contain a parsable integer.
     * @see        java.lang.Integer#parseInt&#40;java.lang.String, int&#41;
     */
    public Integer&#40;String s&#41; throws NumberFormatException &#123;
	this.value = parseInt&#40;s, 10&#41;;
    &#125;

    /**
     * Returns the value of this <code>Integer</code> as a
     * <code>byte</code>.
     */
    public byte byteValue&#40;&#41; &#123;
	return &#40;byte&#41;value;
    &#125;

    /**
     * Returns the value of this <code>Integer</code> as a
     * <code>short</code>.
     */
    public short shortValue&#40;&#41; &#123;
	return &#40;short&#41;value;
    &#125;

    /**
     * Returns the value of this <code>Integer</code> as an
     * <code>int</code>.
     */
    public int intValue&#40;&#41; &#123;
	return value;
    &#125;

    /**
     * Returns the value of this <code>Integer</code> as a
     * <code>long</code>.
     */
    public long longValue&#40;&#41; &#123;
	return &#40;long&#41;value;
    &#125;

    /**
     * Returns the value of this <code>Integer</code> as a
     * <code>float</code>.
     */
    public float floatValue&#40;&#41; &#123;
	return &#40;float&#41;value;
    &#125;

    /**
     * Returns the value of this <code>Integer</code> as a
     * <code>double</code>.
     */
    public double doubleValue&#40;&#41; &#123;
	return &#40;double&#41;value;
    &#125;

    /**
     * Returns a <code>String</code> object representing this
     * <code>Integer</code>'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 &#123;@link
     * java.lang.Integer#toString&#40;int&#41;&#125; method.
     *
     * @return  a string representation of the value of this object in
     *          base&nbsp;10.
     */
    public String toString&#40;&#41; &#123;
	return String.valueOf&#40;value&#41;;
    &#125;

    /**
     * Returns a hash code for this <code>Integer</code>.
     *
     * @return  a hash code value for this object, equal to the 
     *          primitive <code>int</code> value represented by this 
     *          <code>Integer</code> object. 
     */
    public int hashCode&#40;&#41; &#123;
	return value;
    &#125;

    /**
     * Compares this object to the specified object.  The result is
     * <code>true</code> if and only if the argument is not
     * <code>null</code> and is an <code>Integer</code> object that
     * contains the same <code>int</code> value as this object.
     *
     * @param   obj   the object to compare with.
     * @return  <code>true</code> if the objects are the same;
     *          <code>false</code> otherwise.
     */
    public boolean equals&#40;Object obj&#41; &#123;
	if &#40;obj instanceof Integer&#41; &#123;
	    return value == &#40;&#40;Integer&#41;obj&#41;.intValue&#40;&#41;;
	&#125;
	return false;
    &#125;

    /**
     * Determines the integer value of the system property with the
     * specified name.
     * <p>
     * The first argument is treated as the name of a system property. 
     * System properties are accessible through the 
     * &#123;@link java.lang.System#getProperty&#40;java.lang.String&#41;&#125; method. The 
     * string value of this property is then interpreted as an integer 
     * value and an <code>Integer</code> object representing this value is 
     * returned. Details of possible numeric formats can be found with 
     * the definition of <code>getProperty</code>. 
     * <p>
     * If there is no property with the specified name, if the specified name
     * is empty or <code>null</code>, or if the property does not have 
     * the correct numeric format, then <code>null</code> is returned.
     * <p>
     * In other words, this method returns an <code>Integer</code>
     * object equal to the value of&#58;
     *
     * <blockquote><code>
     * getInteger&#40;nm, null&#41;
     * </code></blockquote>
     *
     * @param   nm   property name.
     * @return  the <code>Integer</code> value of the property.
     * @see     java.lang.System#getProperty&#40;java.lang.String&#41;
     * @see     java.lang.System#getProperty&#40;java.lang.String, java.lang.String&#41;
     */
    public static Integer getInteger&#40;String nm&#41; &#123;
	return getInteger&#40;nm, null&#41;;
    &#125;

    /**
     * Determines the integer value of the system property with the
     * specified name.
     * <p>
     * The first argument is treated as the name of a system property.
     * System properties are accessible through the &#123;@link
     * java.lang.System#getProperty&#40;java.lang.String&#41;&#125; method. The 
     * string value of this property is then interpreted as an integer 
     * value and an <code>Integer</code> object representing this value is 
     * returned. Details of possible numeric formats can be found with 
     * the definition of <code>getProperty</code>. 
     * <p>
     * The second argument is the default value. An <code>Integer</code> 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
     *  <code>null</code>.
     * <p>
     * In other words, this method returns an <code>Integer</code> object 
     * equal to the value of&#58;
     * <blockquote><code>
     * getInteger&#40;nm, new Integer&#40;val&#41;&#41;
     * </code></blockquote>
     * but in practice it may be implemented in a manner such as&#58; 
     * <blockquote><pre>
     * Integer result = getInteger&#40;nm, null&#41;;
     * return &#40;result == null&#41; ? new Integer&#40;val&#41; &#58; result;
     * </pre></blockquote>
     * to avoid the unnecessary allocation of an <code>Integer</code> 
     * object when the default value is not needed. 
     *
     * @param   nm   property name.
     * @param   val   default value.
     * @return  the <code>Integer</code> value of the property.
     * @see     java.lang.System#getProperty&#40;java.lang.String&#41;
     * @see     java.lang.System#getProperty&#40;java.lang.String, java.lang.String&#41;
     */
    public static Integer getInteger&#40;String nm, int val&#41; &#123;
        Integer result = getInteger&#40;nm, null&#41;;
        return &#40;result == null&#41; ? Integer.valueOf&#40;val&#41; &#58; result;
    &#125;

    /**
     * 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 through the
     * &#123;@link java.lang.System#getProperty&#40;java.lang.String&#41;&#125; method.
     * The string value of this property is then interpreted as an
     * integer value, as per the <code>Integer.decode</code> method,
     * and an <code>Integer</code> object representing this value is
     * returned.
     * <p>
     * <ul><li>If the property value begins with the two ASCII characters 
     *         <code>0x</code> or the ASCII character <code>#</code>, not 
     *      followed by a minus sign, then the rest of it is parsed as a 
     *      hexadecimal integer exactly as by the method 
     *      &#123;@link #valueOf&#40;java.lang.String, int&#41;&#125; with radix 16. 
     * <li>If the property value begins with the ASCII character 
     *     <code>0</code> followed by another character, it is parsed as an 
     *     octal integer exactly as by the method 
     *     &#123;@link #valueOf&#40;java.lang.String, int&#41;&#125; with radix 8. 
     * <li>Otherwise, the property value is parsed as a decimal integer 
     * exactly as by the method &#123;@link #valueOf&#40;java.lang.String, int&#41;&#125; 
     * with radix 10. 
     * </ul><p>
     * 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 <code>null</code>.
     *
     * @param   nm   property name.
     * @param   val   default value.
     * @return  the <code>Integer</code> value of the property.
     * @see     java.lang.System#getProperty&#40;java.lang.String&#41;
     * @see java.lang.System#getProperty&#40;java.lang.String, java.lang.String&#41;
     * @see java.lang.Integer#decode
     */
    public static Integer getInteger&#40;String nm, Integer val&#41; &#123;
	String v = null;
        try &#123;
            v = System.getProperty&#40;nm&#41;;
        &#125; catch &#40;IllegalArgumentException e&#41; &#123;
        &#125; catch &#40;NullPointerException e&#41; &#123;
        &#125;
	if &#40;v != null&#41; &#123;
	    try &#123;
		return Integer.decode&#40;v&#41;;
	    &#125; catch &#40;NumberFormatException e&#41; &#123;
	    &#125;
	&#125;
	return val;
    &#125;

    /**
     * Decodes a <code>String</code> into an <code>Integer</code>.
     * Accepts decimal, hexadecimal, and octal numbers given
     * by the following grammar&#58;
     *
     * <blockquote>
     * <dl>
     * <dt><i>DecodableString&#58;</i>
     * <dd><i>Sign<sub>opt</sub> DecimalNumeral</i>
     * <dd><i>Sign<sub>opt</sub></i> <code>0x</code> <i>HexDigits</i>
     * <dd><i>Sign<sub>opt</sub></i> <code>0X</code> <i>HexDigits</i>
     * <dd><i>Sign<sub>opt</sub></i> <code>#</code> <i>HexDigits</i>
     * <dd><i>Sign<sub>opt</sub></i> <code>0</code> <i>OctalDigits</i>
     * <p>
     * <dt><i>Sign&#58;</i>
     * <dd><code>-</code>
     * </dl>
     * </blockquote>
     *
     * <i>DecimalNumeral</i>, <i>HexDigits</i>, and <i>OctalDigits</i>
     * are defined in <a href="http&#58;//java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#48282">&sect;3.10.1</a> 
     * of the <a href="http&#58;//java.sun.com/docs/books/jls/html/">Java 
     * Language Specification</a>.
     * <p>
     * The sequence of characters following an &#40;optional&#41; negative
     * sign and/or radix specifier &#40;&quot;<code>0x</code>&quot;,
     * &quot;<code>0X</code>&quot;, &quot;<code>#</code>&quot;, or
     * leading zero&#41; is parsed as by the <code>Integer.parseInt</code>
     * method with the indicated radix &#40;10, 16, or 8&#41;.  This sequence
     * of characters must represent a positive value or a &#123;@link
     * NumberFormatException&#125; will be thrown.  The result is negated
     * if first character of the specified <code>String</code> is the
     * minus sign.  No whitespace characters are permitted in the
     * <code>String</code>.
     *
     * @param     nm the <code>String</code> to decode.
     * @return    a <code>Integer</code> object holding the <code>int</code>
     *		   value represented by <code>nm</code>
     * @exception NumberFormatException  if the <code>String</code> does not
     *            contain a parsable integer.
     * @see java.lang.Integer#parseInt&#40;java.lang.String, int&#41;
     */
    public static Integer decode&#40;String nm&#41; throws NumberFormatException &#123;
        int radix = 10;
        int index = 0;
        boolean negative = false;
        Integer result;

        // Handle minus sign, if present
        if &#40;nm.startsWith&#40;"-"&#41;&#41; &#123;
            negative = true;
            index++;
        &#125;

        // Handle radix specifier, if present
	if &#40;nm.startsWith&#40;"0x", index&#41; || nm.startsWith&#40;"0X", index&#41;&#41; &#123;
	    index += 2;
            radix = 16;
	&#125;
	else if &#40;nm.startsWith&#40;"#", index&#41;&#41; &#123;
	    index ++;
            radix = 16;
	&#125;
	else if &#40;nm.startsWith&#40;"0", index&#41; && nm.length&#40;&#41; > 1 + index&#41; &#123;
	    index ++;
            radix = 8;
	&#125;

        if &#40;nm.startsWith&#40;"-", index&#41;&#41;
            throw new NumberFormatException&#40;"Negative sign in wrong position"&#41;;

        try &#123;
            result = Integer.valueOf&#40;nm.substring&#40;index&#41;, radix&#41;;
            result = negative ? Integer.valueOf&#40;-result.intValue&#40;&#41;&#41; &#58; result;
        &#125; catch &#40;NumberFormatException e&#41; &#123;
            // If number is Integer.MIN_VALUE, we'll end up here. The next line
            // handles this case, and causes any genuine format error to be
            // rethrown.
            String constant = negative ? "-" + nm.substring&#40;index&#41;
                                       &#58; nm.substring&#40;index&#41;;
            result = Integer.valueOf&#40;constant, radix&#41;;
        &#125;
        return result;
    &#125;

    /**
     * Compares two <code>Integer</code> objects numerically.
     *
     * @param   anotherInteger   the <code>Integer</code> to be compared.
     * @return	the value <code>0</code> if this <code>Integer</code> is
     * 		equal to the argument <code>Integer</code>; a value less than
     * 		<code>0</code> if this <code>Integer</code> is numerically less
     * 		than the argument <code>Integer</code>; and a value greater 
     * 		than <code>0</code> if this <code>Integer</code> is numerically
     * 		 greater than the argument <code>Integer</code> &#40;signed
     * 		 comparison&#41;.
     * @since   1.2
     */
    public int compareTo&#40;Integer anotherInteger&#41; &#123;
	int thisVal = this.value;
	int anotherVal = anotherInteger.value;
	return &#40;thisVal<anotherVal ? -1 &#58; &#40;thisVal==anotherVal ? 0 &#58; 1&#41;&#41;;
    &#125;


    // Bit twiddling

    /**
     * The number of bits used to represent an <tt>int</tt> value in two's
     * complement binary form.
     *
     * @since 1.5
     */
    public static final int SIZE = 32;
 
    /**
     * Returns an <tt>int</tt> value with at most a single one-bit, in the
     * position of the highest-order &#40;"leftmost"&#41; one-bit in the specified
     * <tt>int</tt> value.  Returns zero if the specified value has no
     * one-bits in its two's complement binary representation, that is, if it
     * is equal to zero.
     *
     * @return an <tt>int</tt> value with a single one-bit, in the position
     *     of the highest-order one-bit in the specified value, or zero if
     *     the specified value is itself equal to zero.
     * @since 1.5
     */
    public static int highestOneBit&#40;int i&#41; &#123;
        // HD, Figure 3-1
        i |= &#40;i >>  1&#41;;
        i |= &#40;i >>  2&#41;;
        i |= &#40;i >>  4&#41;;
        i |= &#40;i >>  8&#41;;
        i |= &#40;i >> 16&#41;;
        return i - &#40;i >>> 1&#41;;
    &#125;
 
    /**
     * Returns an <tt>int</tt> value with at most a single one-bit, in the
     * position of the lowest-order &#40;"rightmost"&#41; one-bit in the specified
     * <tt>int</tt> value.  Returns zero if the specified value has no
     * one-bits in its two's complement binary representation, that is, if it
     * is equal to zero.
     *
     * @return an <tt>int</tt> value with a single one-bit, in the position
     *     of the lowest-order one-bit in the specified value, or zero if
     *     the specified value is itself equal to zero.
     * @since 1.5
     */
    public static int lowestOneBit&#40;int i&#41; &#123;
        // HD, Section 2-1
        return i & -i;
    &#125;
 
    /**
     * Returns the number of zero bits preceding the highest-order
     * &#40;"leftmost"&#41; one-bit in the two's complement binary representation
     * of the specified <tt>int</tt> value.  Returns 32 if the
     * specified value has no one-bits in its two's complement representation,
     * in other words if it is equal to zero.
     *
     * <p>Note that this method is closely related to the logarithm base 2.
     * For all positive <tt>int</tt> values x&#58;
     * <ul>
     * <li>floor&#40;log<sub>2</sub>&#40;x&#41;&#41; = <tt>31 - numberOfLeadingZeros&#40;x&#41;</tt>
     * <li>ceil&#40;log<sub>2</sub>&#40;x&#41;&#41; = <tt>32 - numberOfLeadingZeros&#40;x - 1&#41;</tt>
     * </ul>
     *
     * @return the number of zero bits preceding the highest-order
     *     &#40;"leftmost"&#41; one-bit in the two's complement binary representation
     *     of the specified <tt>int</tt> value, or 32 if the value
     *     is equal to zero.
     * @since 1.5
     */
    public static int numberOfLeadingZeros&#40;int i&#41; &#123;
        // HD, Figure 5-6
        if &#40;i == 0&#41;
            return 32;
        int n = 1;
        if &#40;i >>> 16 == 0&#41; &#123; n += 16; i <<= 16; &#125;
        if &#40;i >>> 24 == 0&#41; &#123; n +=  8; i <<=  8; &#125;
        if &#40;i >>> 28 == 0&#41; &#123; n +=  4; i <<=  4; &#125;
        if &#40;i >>> 30 == 0&#41; &#123; n +=  2; i <<=  2; &#125;
        n -= i >>> 31;
        return n;
    &#125;
 
    /**
     * Returns the number of zero bits following the lowest-order &#40;"rightmost"&#41;
     * one-bit in the two's complement binary representation of the specified
     * <tt>int</tt> value.  Returns 32 if the specified value has no
     * one-bits in its two's complement representation, in other words if it is
     * equal to zero.
     *
     * @return the number of zero bits following the lowest-order &#40;"rightmost"&#41;
     *     one-bit in the two's complement binary representation of the
     *     specified <tt>int</tt> value, or 32 if the value is equal
     *     to zero.
     * @since 1.5
     */
    public static int numberOfTrailingZeros&#40;int i&#41; &#123;
        // HD, Figure 5-14
	int y;
	if &#40;i == 0&#41; return 32;
	int n = 31;
	y = i <<16; if &#40;y != 0&#41; &#123; n = n -16; i = y; &#125;
	y = i << 8; if &#40;y != 0&#41; &#123; n = n - 8; i = y; &#125;
	y = i << 4; if &#40;y != 0&#41; &#123; n = n - 4; i = y; &#125;
	y = i << 2; if &#40;y != 0&#41; &#123; n = n - 2; i = y; &#125;
	return n - &#40;&#40;i << 1&#41; >>> 31&#41;;
    &#125;
 
    /**
     * Returns the number of one-bits in the two's complement binary
     * representation of the specified <tt>int</tt> value.  This function is
     * sometimes referred to as the <i>population count</i>.
     *
     * @return the number of one-bits in the two's complement binary
     *     representation of the specified <tt>int</tt> value.
     * @since 1.5
     */
    public static int bitCount&#40;int i&#41; &#123;
        // HD, Figure 5-2
	i = i - &#40;&#40;i >>> 1&#41; & 0x55555555&#41;;
	i = &#40;i & 0x33333333&#41; + &#40;&#40;i >>> 2&#41; & 0x33333333&#41;;
	i = &#40;i + &#40;i >>> 4&#41;&#41; & 0x0f0f0f0f;
	i = i + &#40;i >>> 8&#41;;
	i = i + &#40;i >>> 16&#41;;
	return i & 0x3f;
    &#125;
 
    /**
     * Returns the value obtained by rotating the two's complement binary
     * representation of the specified <tt>int</tt> value left by the
     * specified number of bits.  &#40;Bits shifted out of the left hand, or
     * high-order, side reenter on the right, or low-order.&#41;
     *
     * <p>Note that left rotation with a negative distance is equivalent to
     * right rotation&#58; <tt>rotateLeft&#40;val, -distance&#41; == rotateRight&#40;val,
     * distance&#41;</tt>.  Note also that rotation by any multiple of 32 is a
     * no-op, so all but the last five bits of the rotation distance can be
     * ignored, even if the distance is negative&#58; <tt>rotateLeft&#40;val,
     * distance&#41; == rotateLeft&#40;val, distance & 0x1F&#41;</tt>.
     *
     * @return the value obtained by rotating the two's complement binary
     *     representation of the specified <tt>int</tt> value left by the
     *     specified number of bits.
     * @since 1.5
     */
    public static int rotateLeft&#40;int i, int distance&#41; &#123;
        return &#40;i << distance&#41; | &#40;i >>> -distance&#41;;
    &#125;

    /**
     * Returns the value obtained by rotating the two's complement binary
     * representation of the specified <tt>int</tt> value right by the
     * specified number of bits.  &#40;Bits shifted out of the right hand, or
     * low-order, side reenter on the left, or high-order.&#41;
     *
     * <p>Note that right rotation with a negative distance is equivalent to
     * left rotation&#58; <tt>rotateRight&#40;val, -distance&#41; == rotateLeft&#40;val,
     * distance&#41;</tt>.  Note also that rotation by any multiple of 32 is a
     * no-op, so all but the last five bits of the rotation distance can be
     * ignored, even if the distance is negative&#58; <tt>rotateRight&#40;val,
     * distance&#41; == rotateRight&#40;val, distance & 0x1F&#41;</tt>.
     *
     * @return the value obtained by rotating the two's complement binary
     *     representation of the specified <tt>int</tt> value right by the
     *     specified number of bits.
     * @since 1.5
     */
    public static int rotateRight&#40;int i, int distance&#41; &#123;
        return &#40;i >>> distance&#41; | &#40;i << -distance&#41;;
    &#125;
 
    /**
     * Returns the value obtained by reversing the order of the bits in the
     * two's complement binary representation of the specified <tt>int</tt>
     * value.
     *
     * @return the value obtained by reversing order of the bits in the
     *     specified <tt>int</tt> value.
     * @since 1.5
     */
    public static int reverse&#40;int i&#41; &#123;
        // HD, Figure 7-1
	i = &#40;i & 0x55555555&#41; << 1 | &#40;i >>> 1&#41; & 0x55555555;
	i = &#40;i & 0x33333333&#41; << 2 | &#40;i >>> 2&#41; & 0x33333333;
	i = &#40;i & 0x0f0f0f0f&#41; << 4 | &#40;i >>> 4&#41; & 0x0f0f0f0f;
	i = &#40;i << 24&#41; | &#40;&#40;i & 0xff00&#41; << 8&#41; |
	    &#40;&#40;i >>> 8&#41; & 0xff00&#41; | &#40;i >>> 24&#41;;
	return i;
    &#125;
 
    /**
     * Returns the signum function of the specified <tt>int</tt> value.  &#40;The
     * return value is -1 if the specified value is negative; 0 if the
     * specified value is zero; and 1 if the specified value is positive.&#41;
     *
     * @return the signum function of the specified <tt>int</tt> value.
     * @since 1.5
     */
    public static int signum&#40;int i&#41; &#123;
        // HD, Section 2-7
        return &#40;i >> 31&#41; | &#40;-i >>> 31&#41;;
    &#125;
 
    /**
     * Returns the value obtained by reversing the order of the bytes in the
     * two's complement representation of the specified <tt>int</tt> value.
     *
     * @return the value obtained by reversing the bytes in the specified
     *     <tt>int</tt> value.
     * @since 1.5
     */
    public static int reverseBytes&#40;int i&#41; &#123;
        return &#40;&#40;i >>> 24&#41;           &#41; |
               &#40;&#40;i >>   8&#41; &   0xFF00&#41; |
               &#40;&#40;i <<   8&#41; & 0xFF0000&#41; |
               &#40;&#40;i << 24&#41;&#41;;
    &#125;

    /** use serialVersionUID from JDK 1.0.2 for interoperability */
    private static final long serialVersionUID = 1360826667806852920L;
&#125;


JOHNYS20
Δημοσιεύσεις: 28
Εγγραφή: 29 Νοέμ 2010 18:08

Klaseis java

Δημοσίευση από JOHNYS20 » 18 Φεβ 2011 17:04

thelo na vro tis immutable klaseis ton integer,char,string,boolean,long kai na tis metatrepso se kanonikes diladi na einai metablites xereis poy tha tis vro?

pimpogio
Δημοσιεύσεις: 1080
Εγγραφή: 28 Δεκ 2010 14:08

Klaseis java

Δημοσίευση από pimpogio » 18 Φεβ 2011 23:02

σου ειπα στο java.lang ειναι μεσα...

Μονο που αυτο που θες να κανεις ειναι μια πατατα
γιατι θα υπαρξουνε μετα τεραστια προβληματα...

Δεν θα ειναι thread safe οι classes αυτες τι θα κανεις με το hashCode() ? ktlp...

Φτιαξε καινουργιες δικες σου mutable και ασε τις classes της java ησυχες...

JOHNYS20
Δημοσιεύσεις: 28
Εγγραφή: 29 Νοέμ 2010 18:08

Klaseis java

Δημοσίευση από JOHNYS20 » 19 Φεβ 2011 17:05

μπηκα στο java.lang alla dn tis vrika mipos boreis na m peis tn diethinsi.exo ergasia na kano tis immutable klaseis tis java metablhtes gia ayto

pimpogio
Δημοσιεύσεις: 1080
Εγγραφή: 28 Δεκ 2010 14:08

Klaseis java

Δημοσίευση από pimpogio » 24 Φεβ 2011 18:57

δες το αρχειο src.zip εκει μεσα ειναι..

εγω παντως στο java.lang τις βλεπω ολες μια χαρα

Απάντηση

Επιστροφή στο “Java”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 0 επισκέπτες