< prev index next >

src/java.base/share/classes/java/lang/String.java

Print this page

        

@@ -248,11 +248,11 @@
      * the character array does not affect the newly created string.
      *
      * @param  value
      *         The initial value of the string
      */
-    public String(char value[]) {
+    public String(char[] value) {
         this(value, 0, value.length, null);
     }
 
     /**
      * Allocates a new {@code String} that contains characters from a subarray

@@ -273,11 +273,11 @@
      *
      * @throws  IndexOutOfBoundsException
      *          If {@code offset} is negative, {@code count} is negative, or
      *          {@code offset} is greater than {@code value.length - count}
      */
-    public String(char value[], int offset, int count) {
+    public String(char[] value, int offset, int count) {
         this(value, offset, count, rangeCheck(value, offset, count));
     }
 
     private static Void rangeCheck(char[] value, int offset, int count) {
         checkBoundsOffCount(offset, count, value.length);

@@ -370,11 +370,11 @@
      * @see  #String(byte[], java.lang.String)
      * @see  #String(byte[], java.nio.charset.Charset)
      * @see  #String(byte[])
      */
     @Deprecated(since="1.1")
-    public String(byte ascii[], int hibyte, int offset, int count) {
+    public String(byte[] ascii, int hibyte, int offset, int count) {
         checkBoundsOffCount(offset, count, ascii.length);
         if (count == 0) {
             this.value = "".value;
             this.coder = "".coder;
             return;

@@ -422,11 +422,11 @@
      * @see  #String(byte[], java.lang.String)
      * @see  #String(byte[], java.nio.charset.Charset)
      * @see  #String(byte[])
      */
     @Deprecated(since="1.1")
-    public String(byte ascii[], int hibyte) {
+    public String(byte[] ascii, int hibyte) {
         this(ascii, hibyte, 0, ascii.length);
     }
 
     /**
      * Constructs a new {@code String} by decoding the specified subarray of

@@ -459,11 +459,11 @@
      *          If {@code offset} is negative, {@code length} is negative, or
      *          {@code offset} is greater than {@code bytes.length - length}
      *
      * @since  1.1
      */
-    public String(byte bytes[], int offset, int length, String charsetName)
+    public String(byte[] bytes, int offset, int length, String charsetName)
             throws UnsupportedEncodingException {
         if (charsetName == null)
             throw new NullPointerException("charsetName");
         checkBoundsOffCount(offset, length, bytes.length);
         StringCoding.Result ret =

@@ -500,11 +500,11 @@
      *          If {@code offset} is negative, {@code length} is negative, or
      *          {@code offset} is greater than {@code bytes.length - length}
      *
      * @since  1.6
      */
-    public String(byte bytes[], int offset, int length, Charset charset) {
+    public String(byte[] bytes, int offset, int length, Charset charset) {
         if (charset == null)
             throw new NullPointerException("charset");
         checkBoundsOffCount(offset, length, bytes.length);
         StringCoding.Result ret =
             StringCoding.decode(charset, bytes, offset, length);

@@ -533,11 +533,11 @@
      * @throws  UnsupportedEncodingException
      *          If the named charset is not supported
      *
      * @since  1.1
      */
-    public String(byte bytes[], String charsetName)
+    public String(byte[] bytes, String charsetName)
             throws UnsupportedEncodingException {
         this(bytes, 0, bytes.length, charsetName);
     }
 
     /**

@@ -558,11 +558,11 @@
      *         The {@linkplain java.nio.charset.Charset charset} to be used to
      *         decode the {@code bytes}
      *
      * @since  1.6
      */
-    public String(byte bytes[], Charset charset) {
+    public String(byte[] bytes, Charset charset) {
         this(bytes, 0, bytes.length, charset);
     }
 
     /**
      * Constructs a new {@code String} by decoding the specified subarray of

@@ -588,11 +588,11 @@
      *          If {@code offset} is negative, {@code length} is negative, or
      *          {@code offset} is greater than {@code bytes.length - length}
      *
      * @since  1.1
      */
-    public String(byte bytes[], int offset, int length) {
+    public String(byte[] bytes, int offset, int length) {
         checkBoundsOffCount(offset, length, bytes.length);
         StringCoding.Result ret = StringCoding.decode(bytes, offset, length);
         this.value = ret.value;
         this.coder = ret.coder;
     }

@@ -851,11 +851,11 @@
      *                string
      *            <li>{@code dstBegin} is negative
      *            <li>{@code dstBegin+(srcEnd-srcBegin)} is larger than
      *                {@code dst.length}</ul>
      */
-    public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
+    public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) {
         checkBoundsBeginEnd(srcBegin, srcEnd, length());
         checkBoundsOffCount(dstBegin, srcEnd - srcBegin, dst.length);
         if (isLatin1()) {
             StringLatin1.getChars(value, srcBegin, srcEnd, dst, dstBegin);
         } else {

@@ -905,11 +905,11 @@
      *            <li> {@code dstBegin+(srcEnd-srcBegin)} is larger than {@code
      *                 dst.length}
      *          </ul>
      */
     @Deprecated(since="1.1")
-    public void getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin) {
+    public void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) {
         checkBoundsBeginEnd(srcBegin, srcEnd, length());
         Objects.requireNonNull(dst);
         checkBoundsOffCount(dstBegin, srcEnd - srcBegin, dst.length);
         if (isLatin1()) {
             StringLatin1.getBytes(value, srcBegin, srcEnd, dst, dstBegin);

@@ -1041,12 +1041,12 @@
     private boolean nonSyncContentEquals(AbstractStringBuilder sb) {
         int len = length();
         if (len != sb.length()) {
             return false;
         }
-        byte v1[] = value;
-        byte v2[] = sb.getValue();
+        byte[] v1 = value;
+        byte[] v2 = sb.getValue();
         if (coder() == sb.getCoder()) {
             int n = v1.length;
             for (int i = 0; i < n; i++) {
                 if (v1[i] != v2[i]) {
                     return false;

@@ -1193,12 +1193,12 @@
      *          is lexicographically less than the string argument; and a
      *          value greater than {@code 0} if this string is
      *          lexicographically greater than the string argument.
      */
     public int compareTo(String anotherString) {
-        byte v1[] = value;
-        byte v2[] = anotherString.value;
+        byte[] v1 = value;
+        byte[] v2 = anotherString.value;
         if (coder() == anotherString.coder()) {
             return isLatin1() ? StringLatin1.compareTo(v1, v2)
                               : StringUTF16.compareTo(v1, v2);
         }
         return isLatin1() ? StringLatin1.compareToUTF16(v1, v2)

@@ -1222,12 +1222,12 @@
             implements Comparator<String>, java.io.Serializable {
         // use serialVersionUID from JDK 1.2.2 for interoperability
         private static final long serialVersionUID = 8575799808933029326L;
 
         public int compare(String s1, String s2) {
-            byte v1[] = s1.value;
-            byte v2[] = s2.value;
+            byte[] v1 = s1.value;
+            byte[] v2 = s2.value;
             if (s1.coder() == s2.coder()) {
                 return s1.isLatin1() ? StringLatin1.compareToCI(v1, v2)
                                      : StringUTF16.compareToCI(v1, v2);
             }
             return s1.isLatin1() ? StringLatin1.compareToCI_UTF16(v1, v2)

@@ -1295,12 +1295,12 @@
      * @return  {@code true} if the specified subregion of this string
      *          exactly matches the specified subregion of the string argument;
      *          {@code false} otherwise.
      */
     public boolean regionMatches(int toffset, String other, int ooffset, int len) {
-        byte tv[] = value;
-        byte ov[] = other.value;
+        byte[] tv = value;
+        byte[] ov = other.value;
         // Note: toffset, ooffset, or len might be near -1>>>1.
         if ((ooffset < 0) || (toffset < 0) ||
              (toffset > (long)length() - len) ||
              (ooffset > (long)other.length() - len)) {
             return false;

@@ -1395,12 +1395,12 @@
         if ((ooffset < 0) || (toffset < 0)
                 || (toffset > (long)length() - len)
                 || (ooffset > (long)other.length() - len)) {
             return false;
         }
-        byte tv[] = value;
-        byte ov[] = other.value;
+        byte[] tv = value;
+        byte[] ov = other.value;
         if (coder() == other.coder()) {
             return isLatin1()
               ? StringLatin1.regionMatchesCI(tv, toffset, ov, ooffset, len)
               : StringUTF16.regionMatchesCI(tv, toffset, ov, ooffset, len);
         }

@@ -1429,12 +1429,12 @@
     public boolean startsWith(String prefix, int toffset) {
         // Note: toffset might be near -1>>>1.
         if (toffset < 0 || toffset > length() - prefix.length()) {
             return false;
         }
-        byte ta[] = value;
-        byte pa[] = prefix.value;
+        byte[] ta = value;
+        byte[] pa = prefix.value;
         int po = 0;
         int pc = pa.length;
         if (coder() == prefix.coder()) {
             int to = isLatin1() ? toffset : toffset << 1;
             while (po < pc) {

@@ -3132,11 +3132,11 @@
      *
      * @param   data     the character array.
      * @return  a {@code String} that contains the characters of the
      *          character array.
      */
-    public static String valueOf(char data[]) {
+    public static String valueOf(char[] data) {
         return new String(data);
     }
 
     /**
      * Returns the string representation of a specific subarray of the

@@ -3156,11 +3156,11 @@
      * @exception IndexOutOfBoundsException if {@code offset} is
      *          negative, or {@code count} is negative, or
      *          {@code offset+count} is larger than
      *          {@code data.length}.
      */
-    public static String valueOf(char data[], int offset, int count) {
+    public static String valueOf(char[] data, int offset, int count) {
         return new String(data, offset, count);
     }
 
     /**
      * Equivalent to {@link #valueOf(char[], int, int)}.

@@ -3173,22 +3173,22 @@
      * @exception IndexOutOfBoundsException if {@code offset} is
      *          negative, or {@code count} is negative, or
      *          {@code offset+count} is larger than
      *          {@code data.length}.
      */
-    public static String copyValueOf(char data[], int offset, int count) {
+    public static String copyValueOf(char[] data, int offset, int count) {
         return new String(data, offset, count);
     }
 
     /**
      * Equivalent to {@link #valueOf(char[])}.
      *
      * @param   data   the character array.
      * @return  a {@code String} that contains the characters of the
      *          character array.
      */
-    public static String copyValueOf(char data[]) {
+    public static String copyValueOf(char[] data) {
         return new String(data);
     }
 
     /**
      * Returns the string representation of the {@code boolean} argument.

@@ -3358,11 +3358,11 @@
      * coders are different, and dst is big enough (range check)
      *
      * @param dstBegin  the char index, not offset of byte[]
      * @param coder     the coder of dst[]
      */
-    void getBytes(byte dst[], int dstBegin, byte coder) {
+    void getBytes(byte[] dst, int dstBegin, byte coder) {
         if (coder() == coder) {
             System.arraycopy(value, 0, dst, dstBegin << coder, value.length);
         } else {    // this.coder == LATIN && coder == UTF16
             StringLatin1.inflate(value, 0, dst, dstBegin, value.length);
         }
< prev index next >