Skip to content

8. 자료구조 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions ArraysExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.sql.SQLOutput;

public class ArraysExample {

public static void main(String[] args) {

// 배열(Arrays)

int[] price = {10000, 9000, 40000, 7000};
String[] mbti = {"INFP", "ENFP", "ISTJ", "ESTP"};

System.out.println(mbti.length);

for(int i = 0; i < mbti.length ; i++){
System.out.println(mbti[i]);
}

// System.out.println(price[0]);
// System.out.println(mbti[0]);
//
// price[1] = 8000;
// System.out.println(price[1]);
//
// System.out.println(price);
}
}
22 changes: 22 additions & 0 deletions ListsExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.ArrayList;

public class ListsExample {

public static void main(String[] args) {

// Lists
// 순서 구분, 중복 허용
// Vector, ArrayList, LinkedList

ArrayList list = new ArrayList(10);
list.add(100);
list.add("INFP");
// ArrayList의 자료형을 명시하지 않은 경우 여러 자료형을 입력 가능

ArrayList<Integer> list_A = new ArrayList<>(10); // 자료형 명시할 경우 객체타입 작성

for(int i = 0; i < list.size(); i++){
System.out.println(list.get(i));
}
}
}
19 changes: 19 additions & 0 deletions MapsExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.HashMap;

public class MapsExample {

public static void main(String[] args) {

// Map
// 키-값 쌍을 요소로 가지는 데이터의 모음, 순서 구분 없음
// 키는 중복 불가, 값은 중복 허용

HashMap map = new HashMap();
map.put("age", 30);
map.put("mbti", "INFP");

System.out.println(map.get("age"));

HashMap<String, String> map_A = new HashMap<>(); // 자료형 명시한 경우
}
}