本文整理了Java中java.lang.StringBuilder.reverse()
方法的一些代码示例,展示了StringBuilder.reverse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuilder.reverse()
方法的具体详情如下:
包路径:java.lang.StringBuilder
类名称:StringBuilder
方法名:reverse
[英]Reverses the order of characters in this builder.
[中]反转此生成器中的字符顺序。
代码示例来源:origin: google/guava
private static CharSequence reverse(CharSequence s) {
return new StringBuilder(s).reverse();
}
}
代码示例来源:origin: prestodb/presto
private static CharSequence reverse(CharSequence s) {
return new StringBuilder(s).reverse();
}
}
代码示例来源:origin: hankcs/HanLP
private static String reverse(String word)
{
return new StringBuilder(word).reverse().toString();
}
代码示例来源:origin: google/j2objc
private static CharSequence reverse(CharSequence s) {
return new StringBuilder(s).reverse();
}
}
代码示例来源:origin: wildfly/wildfly
private static CharSequence reverse(CharSequence s) {
return new StringBuilder(s).reverse();
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* <p>Reverses a String as per {@link StringBuilder#reverse()}.</p>
*
* <p>A {@code null} String returns {@code null}.</p>
*
* <pre>
* StringUtils.reverse(null) = null
* StringUtils.reverse("") = ""
* StringUtils.reverse("bat") = "tab"
* </pre>
*
* @param str the String to reverse, may be null
* @return the reversed String, {@code null} if null String input
*/
public static String reverse(final String str) {
if (str == null) {
return null;
}
return new StringBuilder(str).reverse().toString();
}
代码示例来源:origin: stackoverflow.com
String source = "Hello World";
for (String part : source.split(" ")) {
System.out.print(new StringBuilder(part).reverse().toString());
System.out.print(" ");
}
代码示例来源:origin: thinkaurelius/titan
public static String encode(long num, String symbols) {
Preconditions.checkArgument(num>=0,"Expected non-negative number: " + num);
final int B = symbols.length();
StringBuilder sb = new StringBuilder();
while (num != 0) {
sb.append(symbols.charAt((int) (num % B)));
num /= B;
}
return sb.reverse().toString();
}
代码示例来源:origin: stackoverflow.com
public static boolean isPalindrome(String str) {
return str.equals(new StringBuilder(str).reverse().toString());
}
代码示例来源:origin: aa112901/remusic
public static String reverse(String str) {
return new StringBuilder(str).reverse().toString();
}
代码示例来源:origin: apache/ignite
/**
* Gets a short string version of this ID. Use it only for UI where full version is
* available to the application.
*
* @return Short string version of this ID.
*/
public String shortString() {
return new StringBuilder(Long.toHexString(locId)).reverse().toString();
}
代码示例来源:origin: JanusGraph/janusgraph
public static String encode(long num, String symbols) {
Preconditions.checkArgument(num>=0,"Expected non-negative number: " + num);
final int B = symbols.length();
StringBuilder sb = new StringBuilder();
while (num != 0) {
sb.append(symbols.charAt((int) (num % B)));
num /= B;
}
return sb.reverse().toString();
}
代码示例来源:origin: biezhi/30-seconds-of-java8
public static boolean isPalindrome(String input) {
String s = input.toLowerCase().replaceAll("[\\W_]", "");
return Objects.equals(
s,
new StringBuilder(s).reverse().toString()
);
}
代码示例来源:origin: languagetool-org/languagetool
int getLastDiffPosition(String text1, String text2) {
StringBuilder reverse1 = new StringBuilder(text1.trim()).reverse();
StringBuilder reverse2 = new StringBuilder(text2.trim()).reverse();
int revDiffPos = getFirstDiffPosition(reverse1.toString(), reverse2.toString());
if (revDiffPos != -1) {
return text1.length() - revDiffPos;
} else {
return -1;
}
}
代码示例来源:origin: vavr-io/vavr
@Override
public CharSeq reverse() {
return of(new StringBuilder(back).reverse().toString());
}
代码示例来源:origin: skylot/jadx
/**
* Simplified version of org.apache.commons.lang3.StringUtils.reverse()
*/
public static String reverse(final String str) {
return new StringBuilder(str).reverse().toString();
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public TextValue reverse()
{
StringBuilder stringBuilder = new StringBuilder( value() );
return Values.stringValue( stringBuilder.reverse().toString() );
}
代码示例来源:origin: goldmansachs/gs-collections
public CharAdapter toReversed()
{
StringBuilder builder = new StringBuilder(this.adapted);
return new CharAdapter(builder.reverse().toString());
}
代码示例来源:origin: groovy/groovy-core
public static String reverseToUpperCase(String self) {
StringBuilder sb = new StringBuilder(self.toUpperCase());
return sb.reverse().toString();
}
}
代码示例来源:origin: apache/hive
@Nullable
@Override
public String apply(@Nullable String s) {
if (s == null){
return null;
} else {
StringBuilder sb = new StringBuilder(s);
return sb.toString() + sb.reverse().toString();
}
}
};
内容来源于网络,如有侵权,请联系作者删除!