✔ 아래 Document 참고
https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html
Arrays (Java Platform SE 7 )
Sorts the specified array into ascending numerical order. Implementation note: The sorting algorithm is a Dual-Pivot Quicksort by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm offers O(n log(n)) performance on many data sets that cau
docs.oracle.com
https://www.w3schools.com/java/java_arrays.asp
↓↓↓ 전 개인적으로 여기 w3schools 가 간단하게 보기 쉽게 되어있더라구요 ↓↓↓
Java Arrays
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
www.w3schools.com
배열(Array)이란?
배열은 인덱스와 인덱스에 대응하는 일련의 데이터들로 이루어진 연속적인 자료구조로서, 배열에는 같은 종류의 데이터들이 순차적으로 저장된다.
아래 코드를 읽어보시면 배열(Array)이 어떤식으로 작동하는지 이해하실 수 있을거에요!
Tip ✔
아래 코드를 모두 복사 혹은 다운로드 → IDE 에 붙여넣기 한 다음,
실행해보고 이리저리 코드를 수정해가면서
에러가 뜨면, 왜 에러가 뜨는지 직접 몸소 체험을 해봐야 경험치가 쌓입니다!
이것마저 못하는 게으름뱅이는 코딩 ㄹㅇ 접어야함 ㅅㄱ
아래 댓글창에 질문 언제든지 해주세요!
(시간되는 대로 답변해드리겠습니다)
소스코드 다운 필요하신분은 아래 첨부파일 확인해주세요!
에러를 많이 내 볼수록 실력이 향상 되는거 알고 계시죠!? 🔥
public class Array {
public static void main(String[] args) {
// Array 만드는 법!
// 방법1)
String[] classGroup = {
"Jooh", "Wan", "Jep", "il"
};
System.out.println(classGroup[0]); // Jooh
System.out.println(classGroup[1]); // wan
System.out.println(classGroup[2]); // Jep
System.out.println(classGroup[3]); // il
// 방법2)
String[] classGroup2 = new String[4];
// ↑ 와 같이 Array의 사이즈를 처음부터 정했으면
// 안에 값(value)가 몇개가 있던 간에
// 그 Array의 length는 처음에 정한 length 길이 만큼 나온다!
classGroup2[0] = "Hello";
System.out.println(classGroup2.length); // 4
classGroup2[1] = "World";
System.out.println(classGroup2.length); // 4
classGroup2[2] = "Hi";
System.out.println(classGroup2.length); // 4
classGroup2[3] = "Bye";
System.out.println(classGroup2.length); // 4
}
}
↓↓↓↓ 코드 다운로드 ↓↓↓↓
'🖥️프로그래밍 언어 > Java' 카테고리의 다른 글
[JAVA] 자바 정적변수(Static variables) = 클래스변수(Class variables) (0) | 2022.09.13 |
---|---|
[JAVA] 자바 Scanner + hasNextInt() (0) | 2022.09.12 |
[JAVA] 자바 메소드(Method) + while문 + 예시 (2) | 2022.09.11 |
[JAVA] 자바 배열(Array) + for문 + for-each문 + 예시 (2) | 2022.09.10 |
[JAVA] 자바 데이터 형 변환(Type Conversion) + 예시 (0) | 2022.09.06 |