本文整理了Java中java.lang.Integer.getChars()
方法的一些代码示例,展示了Integer.getChars()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Integer.getChars()
方法的具体详情如下:
包路径:java.lang.Integer
类名称:Integer
方法名:getChars
[英]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 (exclusive), and working backwards from there. Will fail if i == Integer.MIN_VALUE
[中]将表示整数i的字符放入字符数组buf中。字符从指定索引(排他)的最低有效位开始向后放入缓冲区,并从那里向后工作。如果i==整数,则将失败。最小值
代码示例来源:origin: stackoverflow.com
public AbstractStringBuilder append(int i) {
if (i == Integer.MIN_VALUE) {
append("-2147483648");
return this;
}
int appendedLength = (i < 0) ? Integer.stringSize(-i) + 1
: Integer.stringSize(i);
int spaceNeeded = count + appendedLength;
ensureCapacityInternal(spaceNeeded);
Integer.getChars(i, spaceNeeded, value);
count = spaceNeeded;
return this;
}
代码示例来源:origin: jtulach/bck2brwsr
/**
* Returns a {@code String} 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 {@link
* #toString(int, int)} method.
*
* @param i an integer to be converted.
* @return a string representation of the argument in base 10.
*/
@JavaScriptBody(args = "i", body = "return i.toString();")
public static String toString(int i) {
if (i == Integer.MIN_VALUE)
return "-2147483648";
int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
char[] buf = new char[size];
getChars(i, size, buf);
return new String(buf, 0, size);
}
代码示例来源:origin: stackoverflow.com
// from AbstractStringBuilder
public AbstractStringBuilder append(int i) {
if (i == Integer.MIN_VALUE) {
append("-2147483648");
return this;
}
int appendedLength = (i < 0) ? Integer.stringSize(-i) + 1
: Integer.stringSize(i);
int spaceNeeded = count + appendedLength;
ensureCapacityInternal(spaceNeeded);
Integer.getChars(i, spaceNeeded, value);
count = spaceNeeded;
return this;
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul.mini
/**
* Returns a {@code String} 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 {@link
* #toString(int, int)} method.
*
* @param i an integer to be converted.
* @return a string representation of the argument in base 10.
*/
@JavaScriptBody(args = "i", body = "return i.toString();")
public static String toString(int i) {
if (i == Integer.MIN_VALUE)
return "-2147483648";
int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
char[] buf = new char[size];
getChars(i, size, buf);
return new String(buf, 0, size);
}
代码示例来源:origin: stackoverflow.com
605 public AbstractStringBuilder append(int i) {
606 if (i == Integer.MIN_VALUE) {
607 append("-2147483648");
608 return this;
609 }
610 int appendedLength = (i < 0) ? Integer.stringSize(-i) + 1
611 : Integer.stringSize(i);
612 int spaceNeeded = count + appendedLength;
613 if (spaceNeeded > value.length)
614 expandCapacity(spaceNeeded);
615 Integer.getChars(i, spaceNeeded, value);
616 count = spaceNeeded;
617 return this;
618 }
110 void expandCapacity(int minimumCapacity) {
111 int newCapacity = (value.length + 1) * 2;
112 if (newCapacity < 0) {
113 newCapacity = Integer.MAX_VALUE;
114 } else if (minimumCapacity > newCapacity) {
115 newCapacity = minimumCapacity;
116 }
117 value = Arrays.copyOf(value, newCapacity);
118 }
内容来源于网络,如有侵权,请联系作者删除!