java 这段话什么意思?

来源:百度知道 编辑:UC知道 时间:2024/06/27 10:41:57
public class Functions {
public static String reverse( String text ) {
return new StringBuffer(text).reverse().toString();
}

1. new StringBuffer(text):构造一个字符串缓冲区,并将其内容初始化为指定的字符串内容text

2. new StringBuffer(text).reverse():将text用其反转形式取代。

3.return new StringBuffer(text).reverse().toString();返回字符串text反转后表示形式

public StringBuffer reverse()

该方法的作用是将StringBuffer对象中的内容反转,然后形成新的字符串。例如:

StringBuffer sb = new StringBuffer(“abc”);

sb.reverse();

经过反转以后,对象sb中的内容将变为“cba”。

就是把传过去的字符串String text 反序输出来,比如是传abc输出就是cba
哭了,就差1秒钟啊。

一个类中有一个静态的字符串函数,然后定义一下函数的返回值,仅此而已

作用是吧目标字符串(text)用其反转序列返回。

将text字符串的顺序倒过来 返回