mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8215401: Add isEmpty default method to CharSequence
Reviewed-by: jlaskey, rriggs, jjg, alanb, smarks, darcy
This commit is contained in:
parent
7d330d34f1
commit
113c48f5da
4 changed files with 133 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -87,6 +87,21 @@ public interface CharSequence {
|
|||
*/
|
||||
char charAt(int index);
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this character sequence is empty.
|
||||
*
|
||||
* @implSpec
|
||||
* The default implementation returns the result of calling {@code length() == 0}.
|
||||
*
|
||||
* @return {@code true} if {@link #length()} is {@code 0}, otherwise
|
||||
* {@code false}
|
||||
*
|
||||
* @since 15
|
||||
*/
|
||||
default boolean isEmpty() {
|
||||
return this.length() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code CharSequence} that is a subsequence of this sequence.
|
||||
* The subsequence starts with the {@code char} value at the specified index and
|
||||
|
|
|
@ -684,6 +684,7 @@ public final class String
|
|||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return value.length == 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue