接着调用reverse()方法将字符串反转,最后通过toString()方法获取反转后的字符串,并输出结果。 类图 下面是StringBuffer类的类图: Class01int countint value[]StringBuffer+StringBuffer()+append()+insert()+delete()+reverse() StringBuffer反转字符串的过程 通过上面的示例,我们可以简单认识了StringBuffer类的reverse...
Java.Lang Assembly: Mono.Android.dll Added in 1. C# [Android.Runtime.Register("reverse","()Ljava/lang/StringBuffer;","")]publicJava.Lang.StringBufferReverse(); Returns StringBuffer Attributes RegisterAttribute Remarks Added in 1.0.2.
但是今天在查看StringBuffer源代码的时候发现,其中reverse方法的源代码写的很精妙。源代码如下: 1 public AbstractStringBuilder reverse() { 2 boolean hasSurrogate = false; 3 int n = count - 1; 4 for (int j = (n-1) >> 1; j >= 0; --j) { 5 char temp = value[j]; 6 char temp2 = ...
//string排序 importjava.util.Arrays;importjava.util.Scanner;importjava.math.*;publicclassMain {publicstaticvoidmain(String[] args) {//TODO Auto-generated method stubScanner cin =newScanner(System.in);String str=cin.nextLine();chararr[] =str.toCharArray();Arrays.sort(arr);str=newString(arr);...
reverse()是属于类StringBuffer的一个方法 你在使用StringBuffer这个类之前要先导入他的类库。在代码顶部,package语句下面加一句话:import java.lang.StringBuffer;
// After creating the object, you can reset values of the value field by calling setNewValue(int) method. // This is a mutable class. public class MutableClassExample { private int value; public MutableClassExample(int value) { this.value= value; ...
Let n be the character length of this character sequence (not the length in char values) just prior to execution of the reverse method. Then the character at index k in the new character sequence is equal to the character at index n-k-1 in the old character sequence. Note that the ...
Java.Interop.Expressions Java.Interop.Tools.JavaCallableWrappers Java.IO Java.Lang Java.Lang AbstractMethodError AbstractStringBuilder ArithmeticException ArrayIndexOutOfBoundsException ArrayStoreException AssertionError 布尔 BootstrapMethodError Byte 字符 Character.Subset Character.UnicodeBlock Character.UnicodeScript Cha...
Let n be the character length of this character sequence (not the length in char values) just prior to execution of the reverse method. Then the character at index k in the new character sequence is equal to the character at index n-k-1 in the old character sequence. Note that the ...
[Android.Runtime.Register("insert", "(ILjava/lang/Object;)Ljava/lang/StringBuffer;", "")] public Java.Lang.StringBuffer Insert (int offset, Java.Lang.Object? obj); 参数 offset Int32 obj Object 要插入的对象(可能为 null)。 返回 StringBuffer 属性 RegisterAttribute 例外 StringIndexOutOf...