I just announced the new Spring 5 modules in REST With Spring:

>> CHECK OUT THE COURSE

This article is part of a series:
• Java String.String()
• Java String.copyValueOf()
• Java String.codePointCount()
• Java String.codePointAt()
• Java String.concat()
• Java String.contains()
• Java String.copyValueOf()
• Java String.endsWith()
• Java String.format()
• Java String.getBytes()
• Java String.indexOf()
• Java String.intern()
• Java String.isEmpty()
• Java String.lastIndexOf()
• Java String.regionMatches()
• Java String.replace()
• Java String.replaceAll()
• Java String.split()
• Java String.startsWith()
• Java String.subSequence()
• Java String.substring()
• Java String.toLowerCase()
• Java String.toUpperCase()
• Java String.trim()
• Java String.valueOf()

The method copyValueOf() converts a character array to a String with the same contents. This method is equivalent to valueOf(char[]).

The offset represents the index of the first element to start copying from, and the count represents the number of elements to copy.

Available Signatures

public static String copyValueOf(char[] data)
public static String copyValueOf(char[] data, int offset, int count)

Example

@Test
public void whenCallCopyValueOf_thenStringConstructed() {
    char[] array = new char[] { 'a', 'b', 'c', 'd' };
    
    assertEquals("abcd", String.copyValueOf(array));
}

I just announced the new Spring 5 modules in REST With Spring:

>> CHECK OUT THE LESSONS