[Java/Collection API/List 형] 자바 API, ArrayList, Wrapper Class, 렬렬(sort)

Most Java.util package collection classes are available without package import, including the basic class of Java API java.lang.Details in util package https://blog.naver.com/drv98/222456958749 Most Java.util package collection classes are available without package import.Details in util package https://blog.naver.com/drv98/222456958749

Java API1. API:Application Programming Interface, which means that the library can be programmed…blog.naver.com Java API1. API:Application Programming Interface, which means that the library can be programmed…blog.naver.com

 

 

ArrayList Like the most important array, it is similar to the storage array in the index, but there is no need to size it in advance! Add(value) input get(index) Output ArrayList Like the most important array of lists, it is similar to the storage array in the index, but there is no need to size it in advance! Add(value) inputget(index) output

Import java.util. array list; Import java.util. array list;

It’s generic It’s generic

ArrayList<E> ArrayList<E>

Generics can be class-type (Integer) Generics can be class-type (Integer)

Import java.util. ArrayList;public クラス App {public static void main(String[] args) {rrayList<Integer> list = newArrayList<>();ist.add(7); // 인덱스번호 0 번째 저장ist.add(9);ist.add(123);system.out.println(list.get(0)); // 인덱스번호로 가져옴 system.out.println(list. get(1); systemout。println (list. Import get(2);}} java.util. ArrayList;public クラス App {public static void main(String[] args) {rrayList<Integer> list = newArrayList<>();ist.add(7); // 인덱스번호 0 번째 저장ist.add(9);ist.add(123);system.out.println(list.get(0)); // 인덱스번호로 가져옴 system.out.println(list. get(1); systemout。println (list. get (2));}}

 

How to Use Repeated Statements in ArrayList How to Use Repeated Statements in ArrayList

public class {public static void main(String[] args) {// 리스트에 반복문 사용방법rrayList< を反復する整数> list = newArrayList<>();ist.add(7); // 인덱스번호 0 번째 저장ist.add(9); // 인덱스번호 1 번째 저장ist.add(123); // 인덱스번호 2번째 저장 for(int n : リスト){system.out.println(n); //인덱스 번호까지 사용가능 for(int i= 0; i <list.size(); i++){system.println ” + “}”}(+”); (i.}リストになります public class {public static void main(String[] args) {// 리스트에 반복문 사용방법rrayList< を反復する整数> list = newArrayList<>();ist.add(7); // 인덱스번호 0 번째 저장ist.add(9); // 인덱스번호 1 번째 저장ist.add(123); // 인덱스번호 2번째 저장 for(int n : リスト){system.out.println(n); //인덱스 번호까지 사용가능 for(int i= 0; i <list.size(); i++){system.println ” + “}”}(+”); (i.}リストになります

for each문은 편리합니다. for문은 인덱스 번호까지 사용 가능합니다. 인덱스 번호가 필요한 경우 for문을 간단하게 작성할 때 foreach문 foreach문은 편리합니다. for문은 인덱스 번호까지 사용 가능합니다. 인덱스 번호가 필요한 경우 for문을 간단히 작성할 때는 foreach문

래퍼 클래스 종류 래퍼 클래스 종류

No language detected.

Please check the input language, no language detected.

Please check the input language.

Boxing Basic Type –> Wrapper Class UNBOXING Wrapper Class –> Wrapper Class UNBOXING Wrapper Class –> Wrapper Class

No language detected.

Please check the input language, no language detected.

Please check the input language.

neteger num = New integer (1); // n = num. intValue(); //+ neteger num = New integer (1); // n = num. intValue(); //+

It’s going to be automatic. It’s going to be automatic

= 1에서 통합, //Boxingint n = in a에서 통합, //Boxingint n = in a에서 통합, //Boxing in n = in a에서 통합, //Boxing

 

개체 추가 입력 개체 추가 입력

 

 

people.set(1, new person(“Michael”)); //modification, replacement people.set(1, new person(“Michael”)); //modification, replacement

set index 1번을 Michael로 교체하고 set index 1번을 Michael로 교체합니다.

운명

Collections.sort(); Collections.sort();

수집 클래스로 정렬 방법 수집 클래스로 정렬 방법

공용 클래스 정렬_list {public static void main(String[] args) {rrayList<Double>이 두 배 = 새 ArrayList<Double>(;oubles.add(7.38);oubles.add(3.88);oubles.add(1.45);oubles.add(2.35);oubles.add(9.28);ollections.sort(double); //(double:doubles) {system.out.ln(d);}에 대한 정렬 공용 클래스 정렬_list {public static void main(String[] args) {rrayList<Double>이 두 배 = 새 ArrayList<Double>(;oubles.add(7.38);oubles.add(3.88);oubles.add(1.45);oubles.add(2.35);oubles.add(9.28);ollections.sort(double); //(double:doubles) {system.out.ln(d);}에 대한 정렬

 

고양이 클래스 정렬, 고양이 클래스 정렬

클래스 Cat {private String name;public Cat(String name) {this.name = name;}public String to String() {return name;}클래스 Cat {private String name;public Cat(String name) {this.name = name;}public String to String() {return name;}

 

 

정렬할 비교 대상이 있어야 합니다! 고양이 개체 간 비교 대상 없음 정렬할 비교 대상이 있어야 합니다! 고양이 개체 간 비교 대상 없음

호환 인터페이스로 구현해야 함 호환 인터페이스로 구현해야 함

Class Cat Implementation Compatible<Cat> {//Comparison Method Public int Comparison Target (Cato) {// TODO Auto-Generate Method stubreturn 0;} Class Cat Implementation Compatible<Cat> {//Comparison Method Public Int Comparison Target (Cato) {// TODO Auto-Generate Method stubreturn 0;}

 

클래스 Cat은 Comparable<Cat>{private String name;public Cat(String name) {this.name = name;}public String to String() {return name;}public int comparateTo(Cato) {//비교하여 정수로 크거나 작음을 리턴 return name.comparateTo(o.name )};} 클래스 Cat은 Comparable<Cat>{private String name;public Cat(String name) {this.name = name;}public String to String() {return name;}public int comparateTo(Cato) {//비교하여 정수로 크거나 작음을 리턴 return name.comparateTo(o.name )};}

문자열 비교 방법 : 알파벳 비교 문자열 비교 방법 : 알파벳 비교

감지된 언어가 없습니다.

입력 언어를 확인해 주세요.

 

 

한글은 ㄴㄷ순은 순서입니다. 한글은 ㄴㄷ순은 순서입니다

 

error: Content is protected !!