블로그

[JAVA] Class String, Arrays 주요 메소드 본문

개발자 준비과정/JAVA

[JAVA] Class String, Arrays 주요 메소드

하늘바람a 2024. 3. 6. 01:20

Class String
Package java.lang

Method
더보기
차례대로
Modifier and Type
Method
Description

 

char
charAt(int index)
Returns the char value at the specified index.

boolean
equals(Object anObject)
Compares this string to the specified object.

void
getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
Copies characters from this string into the destination character array.
The first character to be copied is at index srcBegin; the last character to be copied is at index srcEnd-1 (thus the total number of characters to be copied is srcEnd-srcBegin). The characters are copied into the subarray of dst starting at index dstBegin and ending at index:

     dstBegin + (srcEnd-srcBegin) - 1

int
indexOf(String str)
Returns the index within this string of the first occurrence of the specified substring.

boolean
isBlank()
Returns true if the string is empty or contains only white space codepoints, otherwise false.

boolean
isEmpty()
Returns true if, and only if, length() is 0.

int
length()
Returns the length of this string.

String
replace(char oldChar, char newChar)
Returns a string resulting from replacing all occurrences of oldChar in this string with newChar.

 

String[]
split(String regex)
Splits this string around matches of the given regular expression.


String
substring(int beginIndex, int endIndex)
Returns a string that is a substring of this string.
Returns a string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.
Examples:

 "hamburger".substring(4, 8) returns "urge"
 "smiles".substring(1, 5) returns "mile"

char[]
toCharArray()
Converts this string to a new character array.

String
toLowerCase(Locale locale)
Converts all of the characters in this String to lower case using the rules of the given Locale.

String
toUpperCase()
Converts all of the characters in this String to upper case using the rules of the default locale.

String
toString()
This object (which is already a string!)

static String
valueOf(char[] data)
Returns the string representation of the char array argument.

static String
valueOf(int i)
Returns the string representation of the int argument.
The representation is exactly the one returned by the Integer.toString method of one argument.


Class Arrays
Package java.util

Method

 

static char[]
copyOf(char[] original, int newLength)
Copies the specified array, truncating or padding with null characters (if necessary) so the copy has the specified length.

static int[]
copyOf(int[] original, int newLength)
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length.

static char[]
copyOfRange(char[] original, int from, int to)
Copies the specified range of the specified array into a new array.

static boolean
equals(char[] a, char[] a2)
Returns true if the two specified arrays of chars are equal to one another.

static void
fill(int[] a, int val)
Assigns the specified int value to each element of the specified array of ints.

static int
mismatch(boolean[] a, boolean[] b)
Finds and returns the index of the first mismatch between two boolean arrays, otherwise return -1 if no mismatch is found

static void
sort(char[] a)
Sorts the specified array into ascending numerical order.

static void
sort(char[] a, int fromIndex, int toIndex)
Sorts the specified range of the array into ascending order.

static String
toString(double[] a)
Returns a string representation of the contents of the specified array.

'개발자 준비과정 > JAVA' 카테고리의 다른 글

[JAVA] instanceof 연산자  (0) 2024.03.11
[JAVA] 객체 배열...  (3) 2024.03.07
[JAVA] Call By Value  (0) 2024.03.04
[JAVA] 참조타입의 특징  (0) 2024.03.01
[JAVA] 반복문 for, while, do-while 그리고 break,continue  (0) 2024.03.01