Java String toCharArray


자바 문자열 toCharArray  () 메소드는 문자 배열의 문자열을 전환합니다. 

이 메소드는 새롭게 만들어진 문자 배열을 돌려줍니다. 

이것의 길이는 현재 문자열과 유사하고, 이것의 내용은 문자열의 문자와 함께 초기화 됩니다.





Signiture 시그니처


toCharArray 메소드의 Signiture는 아래와 같습니다.


public char[] tocharArray ()







Returns

 

character array





Java String toCharArray() method example



public class StringToCharArrayExample{

public static void main(String args[]){

String s1="hello";

char[] ch=s1.toCharArray();

for(int i=0;i<ch.length;i++){

System.out.print(ch[i]);

}

}} 


output 

hello










Java String toLowerCase()



자바 문자열 toLowerCase() 메소드는 문자열을 소문자로 변환하여 출력합니다. 

다시 말하면, 문자열의 모든 문자는 소문자로 바뀝니다.


toLowerCase() 메소드는 toLowerCase(Locale.getDefault()) 메소드와 동일한 작업을 합니다.

이것은 내부적으로 기본적인 로케일을 사용합니다.






Signiture 시그니처


두 가지 다른 toLowerCase() 메소드가 있습니다. 설명은 아래와 같습니다.



public String toLowerCase()

public String toLowerCase(Locale locale)



toLowerCase()의 다른 2번째 메소드는, 주어진 로케일의 규칙을 사용하여 모든 문자를 소문자로 전환합니다.


 


Returns

 

소문자 문자열





Java String toLowerCase() method example



public class StringLowerExample{

public static void main(String args[]){

String s1="JAVATPOINT HELLO stRIng";

String s1lower=s1.toLowerCase();

System.out.println(s1lower);

}}


output

javatpoint hello string








Java String toUpperCase



자바 문자열 toUpperCase () 메소드는 대문자로 문자열을 반환합니다. 

다시말하면 문자열의 모든 문자를 대문자로 출력합니다.


toUpperCase () 메소드는 toUpperCase(Locale.getDefault()) 메소드와 동일한 작업을 합니다.

이것은 내부적으로 기본 로케일을 사용합니다. 






Signiture 시그니처


2가지 다른 toUpperCase() 메소드가 있습니다. 


public String toUpperCase()

public String toUpperCase(Locale locale)



toUpperCase의 다른 2번째 메소드는, 주어진 로케일의 규칙을 사용하여, 모든 문자를 대문자로 변환합니다. 





Returns

 

대문자 문자열




Java String toUpperCase() method example



public class StringUpperExample{

public static void main(String args[]){

String s1="hello string";

String s1upper=s1.toUpperCase();

System.out.println(s1upper);

}}


output

HELLO STRING








Java String trim



자바 문자열 trim () 메소드는 앞쪽과 뒤쪽의 공백을 제거합니다. 

문자 공간의 유니코드 값은 '\U0020' 입니다. 

trim () 메소드는 문자열 전후 유니코드값을 확인하고,  만약 존재한다면 공백을 제거하고, 문자열을 반환합니다.


trim () 문자열 메소드는 중간 공백을 제거하지 않습니다.





Signiture 시그니처


trim () 메소드의 Signiture는 아래와 같습니다.


public String trim ()






Returns

 

앞 뒤 공백이 생략된 문자열





Java String trim() method example




public class StringTrimExample{

public static void main(String args[]){

String s1=" hello string ";

System.out.println(s1+"javatpoint"); //without trim()

System.out.println(s1.trim()+"javatpoint"); //with trim()

}} 



hello string   javatpoint

hello stringjavatpoint













Java String valueOf


자바 문자열 valueOf () 메소드는 문자열 값을 다른 타입으로 전환합니다. 

valueOf () 메소드로, 당신은 int, long, boolean , character, float, double, object , char array 로 문자열을 전환 할 수 있습니다. 



Signiture 시그니처



public static String valueOf(boolean b)

public static String valueOf(char c)

public static String valueOf(char[] c)

public static String valueOf(int i)

public static String valueOf(long l)

public static String valueOf(float f)

public static String valueOf(double d)

public static String valueOf(Object o)



 


Java String valueOf() method example



public class StringValueOfExample{

public static void main(String args[]){

int value=30;

String s1=String.valueOf(value);

System.out.println(s1+10); //10을 문자열에 연결시킨다.

}}  


output

3010














영어원문내용출처 :http://www.javatpoint.com/

번역,의역 및 작성 : 초코토끼

검수 : 개발토끼

오역 및 오타의 지적은 겸손히 받겠습니다.

+ Recent posts