Integer Flashcards

1
Q

Constructor

A
  • Integer(int value)
  • Integer(String s)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

compare/compareTo

A
  • compare(int x, int y)

Compares two int values numerically. The value returned is identical to what would be returned by:

Integer.valueOf(x).compareTo(Integer.valueOf(y))

  • compareTo(Integer anotherInteger)

Compares two Integer objects numerically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

equals and toString()

A
  • boolean equals(Object obj)

Compares this object to the specified object. The result is true if and only if the argument is not null and is an Integer object that contains the same int value as this object.

  • String toString(int i)

Returns a String object representing the specified integer (in this case, i)

  • String toString()

Returns a String object representing this Integer’s value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

longValue()/floatValue()/doubleValue()/shortValue()/byteValue()

A
  • Returns the value of this Integer as a long/float/double/short/byte/int value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

valueOf(int i/String s)

A
  • valueOf(String s)
  • Returns an Integer object holding the value of the specified String. The argument is interpreted as representing a signed decimal integer, exactly as if the argument were given to the parseInt(java.lang.String) method.
  • valueOf(int i)
  • Returns an Integer instance representing the specified int value. If a new Integer instance is not required, this method should generally be used in preference to the constructor Integer(int), as this method is likely to yield significantly better space and time performance by caching frequently requested values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

parseInt() and parseInt(String s)

A
  • int parseInt(String s) throws NumberFormatException

Parses the string argument as a signed decimal integer.

  • int parseInt(String s, int radix) throws NumberFormatException

Parses the string argument as a signed integer in the radix specified by the second argument.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

highestOneBit(int i)

A
  • highestOneBit(int i)

Returns an int value with at most a single one-bit, in the position of the highest-order (“leftmost”) one-bit in the specified int 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

lowestOneBit(int i)

A
  • lowestOneBit(int i)

Returns an int value with at most a single one-bit, in the position of the lowest-order (“rightmost”) one-bit in the specified int 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

bitCount(int i)

A
  • bitCount(int i)

Returns the number of one-bits in the two’s complement binary representation of the specified int value. This function is sometimes referred to as the population count.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

numberOfLeadingZeros(int i)

A
  • numberOfLeadingZeros(int i)

Returns the number of zero bits preceding the highest-order (“leftmost”) one-bit in the two’s complement binary representation of the specified int 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

numberOfTrailingZeros(int i)

A
  • numberOfTrailingZeros(int i)

Returns the number of zero bits following the lowest-order (“rightmost”) one-bit in the two’s complement binary representation of the specified int 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

toBinaryString(int i)

A
  • toBinaryString(int i)

Returns a string representation of the integer argument as an unsigned integer in base 2.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly