java.lang.StringBuffer.appendCodePoint(int cp)是將codePoint參數的字符串表示形式附加到此序列的方法。
用法:
public StringBuffer appendCodePoint(int cp)
參數:該方法接受整數類型的單個參數cp,表示Unicode代碼點。
返回值:該方法在附加由代碼點表示的字符串之後返回此對象。
例子:
Input: StringBuffer = Apple int cp = 65 Output: AppleA Input: StringBuffer = GeeksforGeeks int cp = 156 Output: GeeksforGeeks? Explanation: Because 65 is the ASCII value for 'A' and 156 is the ASCII value for '?'
以下示例程序旨在說明java.lang.StringBuffer.appendCodePoint(int cp)方法:
示例1:
// Java praogram to illustrate the
// java.lang.StringBuffer.appendCodePoint(int cp)
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
StringBuffer sbf = new StringBuffer("Geeksforgeeks");
System.out.println("String buffer = " + sbf);
// Here it appends the CodePoint as
// String to the string buffer
sbf.appendCodePoint(65);
System.out.println("After appending CodePoint is = " + sbf);
}
}
輸出:
String buffer = Geeksforgeeks After appending CodePoint is = GeeksforgeeksA
示例2:
// Java praogram to illustrate the
// java.lang.StringBuffer.appendCodePoint(int cp)
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
StringBuffer sbf = new StringBuffer("Geeksforgeeks");
System.out.println("String buffer = " + sbf);
// Here it appends the CodePoint as
// string to the string buffer
sbf.appendCodePoint(54);
System.out.println("After appending CodePoint is = " + sbf);
}
}
輸出:
String buffer = Geeksforgeeks After appending CodePoint is = Geeksforgeeks6
示例3:
// Java praogram to illustrate the
// java.lang.StringBuffer.appendCodePoint(int cp)
import java.lang.*;
public class Geeks {
public static void main(String[] args)
{
StringBuffer sbf = new StringBuffer("Geeksforgeeks");
System.out.println("String buffer = " + sbf);
// Here it appends the CodePoint as
// string to the string buffer
sbf.appendCodePoint(43);
System.out.println("After appending CodePoint is = " + sbf);
}
}
輸出:
String buffer = Geeksforgeeks After appending CodePoint is = Geeksforgeeks+
相關用法
- Java StringBuilder appendCodePoint()用法及代碼示例
- Java StringBuffer getChars()用法及代碼示例
- Java StringBuffer codePointAt()用法及代碼示例
- Java StringBuffer ensureCapacity()用法及代碼示例
- Java StringBuffer toString()用法及代碼示例
- Java StringBuffer offsetByCodePoints()用法及代碼示例
- Java StringBuffer setCharAt()用法及代碼示例
- Java StringBuffer trimToSize()用法及代碼示例
- Java StringBuffer codePointBefore()用法及代碼示例
- Java StringBuffer append()用法及代碼示例
- Java StringBuffer substring()用法及代碼示例
- Java StringBuffer lastIndexOf()用法及代碼示例
- Java StringBuffer reverse()用法及代碼示例
- Java StringBuffer replace()用法及代碼示例
- Java StringBuffer delete()用法及代碼示例
注:本文由純淨天空篩選整理自ankita_chowrasia大神的英文原創作品 StringBuffer appendCodePoint() Method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。