本文整理了Java中java.lang.CharSequence.chars()
方法的一些代码示例,展示了CharSequence.chars()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CharSequence.chars()
方法的具体详情如下:
包路径:java.lang.CharSequence
类名称:CharSequence
方法名:chars
暂无
代码示例来源:origin: stackoverflow.com
int streamMethod(final String data, final IntPredicate predicate) {
if (data.chars().anyMatch(predicate)) {
doThrow();
}
return data.length();
}
代码示例来源:origin: stackoverflow.com
Set<Integer> chars = new HashSet<>();
String s = /* Your lowercase string */;
s.length > 25 && s.chars()
.filter(i -> i >= 'a' && i <= 'z') //only alphabet
.filter(chars::add) //add to our tracking set if we reach this point
.filter(i -> chars.size() == 26) //filter the 26th letter found
.findAny().isPresent(); //if the 26th is found, return
代码示例来源:origin: stackoverflow.com
String str = "testString";
//[t, e, s, t, S, t, r, i, n, g]
Character[] charObjectArray =
str.chars().mapToObj(c -> (char)c).toArray(Character[]::new);
代码示例来源:origin: stackoverflow.com
Stream<Character> sch = "abc".chars().mapToObj(i -> (char)i);
sch.forEach(ch -> System.out.printf("%c %s%n", ch, ch.getClass().getName()));
a java.lang.Character
b java.lang.Character
c java.lang.Character
代码示例来源:origin: org.assertj/assertj-core
private boolean containsOneOrMoreWhitespaces(CharSequence actual) {
return actual.chars().anyMatch(Character::isWhitespace);
}
代码示例来源:origin: org.assertj/assertj-core
private boolean strictlyContainsWhitespaces(CharSequence actual) {
return actual.chars().allMatch(Character::isWhitespace);
}
代码示例来源:origin: stackoverflow.com
// avoid this at all costs
int streamParallelMethod(final String data, IntPredicate predicate) {
if (data.chars().parallel().anyMatch(predicate)) {
doThrow();
}
return data.length();
}
代码示例来源:origin: joel-costigliola/assertj-core
private boolean strictlyContainsWhitespaces(CharSequence actual) {
return actual.chars().allMatch(Character::isWhitespace);
}
代码示例来源:origin: joel-costigliola/assertj-core
private boolean containsOneOrMoreWhitespaces(CharSequence actual) {
return actual.chars().anyMatch(Character::isWhitespace);
}
代码示例来源:origin: stackoverflow.com
String someString = "123123";
boolean isNumeric = someString.chars().allMatch( Character::isDigit );
代码示例来源:origin: stackoverflow.com
public static long countUniqueCharacters(String input) {
return input.chars()
.distinct()
.count();
}
代码示例来源:origin: stackoverflow.com
if (data.chars().anyMatch(predicate)) {
doThrow();
if (data.chars().parallel().anyMatch(predicate)) {
doThrow();
代码示例来源:origin: stackoverflow.com
String s = "a.b.c.d";
long result = s.chars().filter(ch -> ch == '.').count();
代码示例来源:origin: stackoverflow.com
public static void main(String[] args)
{
int num = 1234567;
int[]digits = Integer.toString(num).chars().map(c -> c-='0').toArray();
for(int d : digits)
System.out.print(d);
}
代码示例来源:origin: stackoverflow.com
public static int getNumber(String number) {
return number.chars().reduce(0, (a, b) -> 10 * a + b - '0');
}
代码示例来源:origin: aol/cyclops
/**
* Construct a ReactiveSeq from a String
*
* @param input String to construct ReactiveSeq from
* @return ReactiveSeq from a String
*/
public static OneShotStreamX<Integer> fromCharSequence(CharSequence input){
return Streams.<Integer>oneShotStream(input.chars().spliterator(),Optional.empty());
}
代码示例来源:origin: aol/cyclops
public static LazyString of(CharSequence seq){
return fromLazySeq(LazySeq.fromStream( seq.chars().mapToObj(i -> (char) i)));
}
代码示例来源:origin: inferred/FreeBuilder
private void parse(CharSequence chars) {
chars.chars().forEach(c -> parser.parse((char) c));
}
}
代码示例来源:origin: stackoverflow.com
public static BigInteger factorialOf(int x) {
return IntStream.rangeClosed(1, x).mapToObj(BigInteger::valueOf)
.reduce(BigInteger::multiply).orElse(BigInteger.ONE);
}
public static int sumOf(BigInteger y) {
return y.toString().chars().map(i -> i-'0').sum();
}
代码示例来源:origin: stackoverflow.com
public static int countWords(String s) {
return s.chars().reduce(0, (x, y) -> {
if((char)y == ' ')
return x + 1;
return x;
});
}
内容来源于网络,如有侵权,请联系作者删除!