하지만, 예를 들어 객체가 기대되는 경우 메소드 아규먼트로써, char를 객체로 사용할 필요가 있는 경우가 있습니다.
자바 프로그래밍 언어는, 이러한 목적에서 객체 Character 안의 char을 "wraps" 하는 wrapper 클래스를 제공합니다.
타입 Character의 객체에는, 그 타입이 char인 단일 필드가 포함됩니다.
클래스 Character는 또한 글자 조작을 하는데 많은 유용한 클래스 (예, static) 를 제공합니다.
Most of the time, if you are using a single character value, you will use the primitive
char
type. There are times, however, when you need to use a char as an object—for example, as a method argument where an object is expected. The Java programming language provides a wrapper class that "wraps" the char
in a Character
object for this purpose. An object of type Character
contains a single field whose type is char
. This Character
class also offers a number of useful class (i.e., static) methods for manipulating characters.자바 프로그래밍 언어에서, 문자열은 객체입니다.
클래스 String은 60개 이상의 메소드와 13개의 생성자를 갖고 있습니다.
Strings are a sequence of characters and are widely used in Java programming. In the Java programming language, strings are objects. The
String
class has over 60 methods and 13 constructors.가장 일반적으로, String 생성자들 중 하나를 사용하는 대신 다음과 같은 명령문을 가진 문자열을 만듭니다.
Most commonly, you create a string with a statement like
String s = "Hello world!";
rather than using one of the String
constructors.
The String
class has many methods to find and retrieve substrings; these can then be easily reassembled into new strings using the +
concatenation operator.
The String
class also includes a number of utility methods, among them split()
, toLowerCase()
, toUpperCase()
, and valueOf()
. The latter method is indispensable in converting user input strings to numbers. The Number
subclasses also have methods for converting strings to numbers and vice versa.
In addition to the String
class, there is also a StringBuilder
class. Working with StringBuilder
objects can sometimes be more efficient than working with strings. The StringBuilder
class offers a few methods that can be useful for strings, among them reverse()
. In general, however, the String
class has a wider variety of methods.
A string can be converted to a string builder using a StringBuilder
constructor. A string builder can be converted to a string with the toString()
method.
'Java 배우기' 카테고리의 다른 글
Questions and Exercises: Characters and Strings (0) | 2016.01.05 |
---|---|
Autoboxing and Unboxing 오토박싱과 언박싱 (0) | 2016.01.05 |
The StringBuilder Class 클래스 StringBuilder (0) | 2016.01.05 |
Comparing Strings and Portions of Strings 문자열과 문자열 일부의 비교 (0) | 2016.01.05 |
Manipulating Characters in a String String 안에서 글자 조작하기 (0) | 2016.01.05 |
댓글