[JAVA] 5. 참조 타입

H2Soft·2023년 1월 11일

JAVA

목록 보기
5/10

1. 데이터 타입 분류

[기본타입]
byte, char, short, int, long (정수)
float , double (실수)
boolean (논리)
[참조타입]
배열, 열거(enum), 클래스 , 인터페이스

2. 배열

[배열생성]
타입[] 변수이름;
변수이름= new 타입[길이]
[배열길이]
xxx.length;
[출력]
Arrays.toString(변수)
[배열복사]
System.arraycopy()

3. 다차원배열

[2차원배열]

타입[][] 변수이름 
int[][] score;
int[][] score = new int[][]{{1,2,3},{4,5,6}};

[가변배열]

int[][] score = new int[5][];
score[0] = new int [4];
score[1] = new int [3];
score[2] = new int [5];

4.String클래스

char charAt(int index) : 문자열에서 해당 인덱스 문자열 반환
int length() : 문자열 길이
String substring(int form, int to) : 범위만큼 문자열 반환
boolean equals(String str) : 문자열의 내용이 같은지 확인
char[] toCharArray() : 문자열을 char[] 배열로 반환
replace("old","new") : 문자열 대체
indexof(String str) : 문자열 찾기
split(",") : 문자열 분리
profile
프로그램밍 정보 모음

0개의 댓글