Study for Backend/Programming language - Java (33) 썸네일형 리스트형 [Java기초] 변수 및 자료형 // 1. 변수 사용하기 System.out.println("== 변수 사용하기 =="); // 2. 변수 이름 규칙 System.out.println("== 변수 이름 규칙 =="); // 2-1. 문자, 숫자, _(underscore), $ 사용 가능 int appl = 2000; int _apple = 3000; int $apple = 4000; System.out.println(appl); System.out.println("appl = " + appl); System.out.println(_apple); System.out.println("_apple = " + _apple); System.out.println($apple); System.out.println("$apple = " + $appl.. [Java기초] String 클래스 String이란 문자열을 다루는 클래스이다. 특징 1. 값이 초기에 할당되면 그 값은 변경되지 않는다. 2. 리터털로 생성하게되면 String 객체는 String Constant Pool이란 공간에 저장이되며 , new연산자를 이용해 생성하면 Heap영역에 생성된다. 그리고 각 변수는 Stack 메모리에 올라가며 String Constant Pool과 Heap영역에 생성된 객체 메모리 주소값을 참조하게 된다. 3. 공유할 수 있기 때문에 효율적인 메모리 관리가 필요하다. 4. 객체이다. 내장함수 - equals() eqauls()는 두개의 문자열이 동일한 값을 가지고 있는지를 비교하는 함수이다. a == b 와는 다르다. a == b는 문자열 변수의 주소값을 비교하는 것이다. - length() 문자열의.. [Java기초] 문자열을 다루는 String 클래스 메소드 종류 리턴 타입 메소드 이름(매개 변수) 설명 char charAt(int index) 특정 위치의 문자를 리턴합니다. boolean equals(Object anObject) 두 문자열을 비교합니다. byte[] getBytes() byte[]로 리턴합니다. byte[] getBytes(Charset charset) 주어진 문자셋으로 인코딩한 byte[]로 리턴합니다. int indexOf(String str) 문자열 내에서 주어진 문자열의 위치를 리턴합니다. int length() 총 문자의 수를 리턴합니다. String replace(CharSequence target, CharSequence replacement) target 부분을 replacement로 대치한 새로운 문자열을 리턴합니다. Strin.. 이전 1 2 3 4 다음