
๐ ์์ ๊ธฐ๋ก
JVM (Java Virtual Machine) ๋ฉ๋ชจ๋ฆฌ ๊ตฌ์กฐ
- Method Area (Class Area)
- ํด๋์ค ๋ด์ฉ(Byte code : JVM์ด ์ดํดํ ์ ์๋ ์ธ์ด๋ก ๋ณํ๋ ์๋ฐ ์์ค์ฝ๋)๊ฐ ์ ์ฌ๋๋ ์์ญ
- static ๋ณ์ ๋ฐ ์์๊ฐ ์ ์ฌ๋๋ ์์ญ
- Stack Area
- ๋ฉ์๋ ์คํ ๊ณต๊ฐ์ด ์ ์ฌ๋๋ ์์ญ
- ๋ก์ปฌ ๋ณ์ ์ ์ฅ ๊ณต๊ฐ
- Heap Area
- ์์ฑ๋ ๊ฐ์ฒด๊ฐ ์ ์ฌ๋๋ ์์ญ
- ๊ฐ๋น์ง ์ฝ๋ ํฐ : ์ฌ์ฉ๋์ง ์๋ ์ธ์คํด์ค๋ฅผ ์ฐพ์ ๋ฉ๋ชจ๋ฆฌ์์ ์ญ์
maven
- build tool
- ๊ฐ๋ฐ ๋ฐ ์คํ ์ ํ์ํ library๋ค์ ์๊ฒฉ์ง๋ก๋ถํฐ ์๋์ผ๋ก local ์์คํ ์ ๋ค์ด๋ก๋
MVC
- Model - View - Contorller
- ํ๋ฉด๊ณผ ๋ฐ์ดํฐ ์ฒ๋ฆฌ๋ฅผ ๋ถ๋ฆฌํด ์ฝ๋ ๊ฐ์ ์ข ์์ฑ์ ์ค์ด๊ณ ๊ตฌ์ฑ ์์ ๊ฐ์ ์ญํ ์ ๋ช ํํ๊ฒ ํจ
- ๋จ์ํ๊ณ ์ง๊ด์
- ์ ์ง๋ณด์์ ์ฉ์ด, ์ฝ๋ ์ฌ์ฌ์ฉ์ฑ์ด ์ฆ๊ฐ
Model
- ๋ฐ์ดํฐ ์ฒ๋ฆฌ ์์ญ
- ์ค์ ํ๋ก์ ํธ์์๋ ๋ฐ์ดํฐ ๋ฒ ์ด์ค์์ ์ฐ๋, ๋ฐ์ดํฐ ๊ตฌ์กฐ๋ฅผ ํํํ๋ ๊ตฌ์ฑ
- View์ Controller์ ์์กดํ์ง ์์์ผ ํจ
View
- ์ฌ์ฉ์์๊ฒ ์ ๋ณด๋ฅผ ํ์ํ๋ ํ๋ฉด, UI
- ์ฌ์ฉ์์ ์์ฒญ์ ๋ฐ๋ผ ์ ๋ณด ๊ฐฑ์
- Model, Controller์์ ์ข ์์ฑ ์์ด ๊ตฌํ
Controller
- MVC ํจํด์ ํต์ฌ!! ์ฌ์ฉ์ ์์ฒญ์ ์ค์ฌ
- ์ฌ์ฉ์ ์ ๋ ฅ์ ์ฒ๋ฆฌํ๊ณ ์๋ต ์ฒ๋ฆฌ๋ฅผ ์ํด ๋ชจ๋ธ๊ณผ ๋ทฐ๋ฅผ ์กฐ์
CRUD
- ์ํํธ์จ์ด๊ฐ ๊ฐ์ง๋ ๊ธฐ๋ณธ์ ์ธ ๋ฐ์ดํฐ ์ฒ๋ฆฌ ๊ธฐ๋ฅ
Create
- ๋ฐ์ดํฐ ์์ฑ
- SQL์ ๊ด์ ์์ INSERT
Read
- ๋ฐ์ดํฐ ์กฐํ (๊ฒ์, ์ง์)
- SELECT
Update
- ๋ฐ์ดํฐ ์์
Delete
- ๋ฐ์ดํฐ ์ญ์
Java ์ปดํ์ผ ๊ณผ์
- ์๋ฐ ์์ค์ฝ๋ (.java) ์์ฑ
- ์๋ฐ ์ปดํ์ผ๋ฌ๊ฐ ์๋ฐ ์์คํ์ผ(.class) ์ปดํ์ผ, ์๋ฐ byte-code ํ์ผ๋ก ์ปดํจํฐ๊ฐ ์ฝ์ ์ ์๋ ์๋ฐ ๊ฐ์ ๋จธ์ ์ด ์ดํด๊ฐ๋ฅํ ์ฝ๋
- ์ปดํ์ผ๋ byte-code๋ฅผ JVM์ class loader์ ์ ๋ฌ
- Class loader๋ ๋์ ๋ก๋ฉ์ ํตํด ํ์ํ ํด๋์ค๋ค์ ๋ก๋ฉ ๋ฐ ๋งํฌํด ๋ฐํ์ ๋ฐ์ดํฐ ์์ญ, JVM์ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฆผ
- ์คํ ์์ง์ด JVM์ ์ฌ๋ผ์จ byte-code๋ฅผ ๋ช ๋ น์ด ๋จ์๋ก ํ๋์ฉ ์คํ
JAVA ๋ฌธ๋ฒ
์์ฑ์(Constructor)
- ํน์ ๋ฐ์ดํฐ๋ก ๊ฐ์ฒด ์์ฑ, class ๊ธฐ๋ฐ ๊ฐ์ฒด ์์ฑ์ ํธ์ถ๋๋ ํ์ ์์
class Customer{ // ํด๋์ค
// ๊ธฐ๋ณธ ์์ฑ์
Customer(){ //๊ตฌํ
}
}
// ํธ์ถ
new Customer();
for๋ฌธ
for๋ฌธ์ ๋ชจ๋ ์ธ์ด์ ๋ฌธ๋ฒ์ด ํก์ฌ
public void test(){
for(int i = 0; i<5; i++){
System.out.println(i);
}
}
for each๋ฌธ
for(type ๋ณ์๋ช
:iterate){
// ์คํํ ๋ถ๋ถ
}
String[] nums = {"one", "two", "three"};
for(String number: nums){
System.out.println(number);
}
// one
// two
// three
๋ฐฐ์ด
- ๋ฌด์กฐ๊ฑด ๊ฐ์ฒด ํ์
, ๊ธฐ๋ณธ ํ์
, ์ฐธ์กฐ ํ์
๋ ๋ค ์์ฑ ๊ฐ๋ฅ
- ๊ธฐ๋ณธ ํ์ : char, boolean, float, double, byte, short, int, long
- ํ๋ ์ด์์ ๋ฐ์ดํฐ๋ฅผ ํ๋์ ๋ณ์๋ช ์ผ๋ก ๊ด๋ฆฌ, ๊ฐ๊ฐ์ ๋ฐ์ดํฐ ๊ตฌ๋ถ์ index๋ก
- ๋ฐฐ์ด ๊ธธ์ด์ ๊ฐ์ ๋ณด์ ํ length ์๋ ์์ฑ
Customer [] custs = { // ์ฐธ์กฐ ํ์
์ผ๋ก Customer ๊ฐ์ฒด๋ค์ ์์๋ก ๊ฐ์ง ๋ฐฐ์ด
new Customer("์ฐ์", 20);
new Customer("๋์ฝ", 20);
new Customer("์ฌ์", 20);
};

Stack
- heap ์์ญ์ ์์ฑ๋ Object ํ์ ์ ๋ฐ์ดํฐ์ ์ฐธ์กฐ๊ฐ ํ ๋น
- ์์ ํ์ (byte, short, int, long, double, float, boolean, char) ๋ฐ์ดํฐ๊ฐ ๊ฐ๊ณผ ํจ๊ป ํ ๋น
- ์ง์ญ ๋ณ์๋ค์ scope์ ๋ฐ๋ฅธ visibility๋ฅผ ๊ฐ์ง
- ๊ฐ Thread๋ ์์ ๋ง์ stack์ ๊ฐ์ง
Heap
- ๊ธด ์๋ช ์ฃผ๊ธฐ๋ฅผ ๊ฐ๋ ๋ฐ์ดํฐ๋ค์ ์ ์ฅ
- ์ ํ๋ฆฌ์ผ๋์ ์ ๋ชจ๋ ๋ฉ๋ชจ๋ฆฌ ์ค stack์ ์๋ ๋ฐ์ดํฐ๋ฅผ ์ ์ธํ ๋ถ๋ถ
- ๋ชจ๋ Object ํ์ (Integer, String, ArrayList, ..)์ heap ์์ญ์ ์์ฑ
- ๋ช ๊ฐ์ ์ค๋ ๋๊ฐ ์กด์ฌํ๋ ์๊ด์์ด ๋จ ํ๋์ heap ์์ญ๋ง ์กด์ฌ
- Heap ์์ญ์ ์๋ Object๋ค์ ๊ฐ๋ฆฌํค๋ ๋ ํผ๋ฐ์ค ๋ณ์๊ฐ stack์ ์ฌ๋ผ๊ฐ
์์
- ์์ ํด๋์ค๊ฐ ๋ถ๋ชจ ํด๋์ค์ ๋ฉค๋ฒ ๋ณ์์ ๋ฉ์๋๋ฅผ ์์
- ๋ถ๋ชจ ํด๋์ค์ private ์ ๊ทผ ์ ํ์ ๊ฐ๋ ํ๋ ๋ฐ ๋ฉ์๋๋ ์์์ด ๋ฌผ๋ ค๋ฐ์ ์ ์์
- ๋ถ๋ชจ์ ์์ ํด๋์ค๊ฐ ์๋ก ๋ค๋ฅธ ํจํค์ง์ ์๋ค๋ฉด ๋ถ๋ชจ์ default ์ ๊ทผ ์ ํ์ ๊ฐ๋ ํ๋ ๋ฐ ๋ฉ์๋๋ ์์์ด ๋ฌผ๋ ค๋ฐ์ ์ ์์
class Person{ // ๋ถ๋ชจ ํด๋์ค
String name;
public void printName(String name){
this.name = name;
System.out.println("name : " + this;name);
}
}
class Student extends People{ // ๋ถ๋ชจ ํด๋์ค๋ฅผ ์์๋ฐ๋ ์์ ํด๋์ค
int score;
// ์์ฑ์(Contructor)
Student(String name, int scort){
this.name = name;
this.score = score;
}
void printName(){
System.out.println("my name is " + this.name)
}
public void printScore(){
System.out.println("score : " + score);
}
}
public class Main{
public static void main(String[] arge){
Student student = new Student("์ฑ์ฑ", 90);
student.printName(); // ๋ถ๋ชจ ๋ฉ์๋ ํธ์ถ
student.printScore(); // ์์ ๋ฉ์๋ ํธ์ถ
}
}
- ๋ถ๋ชจ ํด๋์ค์์ ๋ง๋ค์ด์ง ๊ฐ์ฒด๋ฅผ ์์ ํด๋์ค์ ์๋ฃํ์ผ๋ก๋ ์ฌ์ฉํ ์ ์์
People people = new Student(); // Student is People (O)
Student student = new People(); // People is Student (X), ์ปดํ์ผ ์ค๋ฅ
ArrayList
- ์๋ฐ์ List ์ธํฐํ์ด์ค๋ฅผ ์์๋ฐ์ ์ฌ๋ฌ ํด๋์ค ์ค ํ๋
- ์ผ๋ฐ ๋ฐฐ์ด๊ณผ ๋์ผํ๊ฒ ์ฐ์๋ ๋ฉ๋ชจ๋ฆฌ ๊ณต๊ฐ์ ์ฌ์ฉํ๊ณ index 0๋ถํฐ ์์
- ๋ฐฐ์ด์ ํฌ๊ธฐ๊ฐ ๊ณ ์ ์ด์ง๋ง ArratList๋ ํฌ๊ธฐ๊ฐ ๊ฐ๋ณ์ ์ผ๋ก ๋ณํจ
import java.util.ArrayList // importํด์ ์ฌ์ฉ
// ArrayList ์์ฑ
ArrayList<Integer> i1 = new ArrayList<Integer>(); // ํ์
์ง์
ArrayList<Integer> i2 = new ArrayList<>(); // ํ์
์๋ต ๊ฐ๋ฅ
ArrayList<Integer> i3 = new ArrayList<>(10); // ์ด๊ธฐ ์ฉ๋(Capacity) ์ค์
ArrayList<Integer> i4 = new ArrayList<>(integers1); // ๋ค๋ฅธ Collection๊ฐ์ผ๋ก ์ด๊ธฐํ
ArrayList<Integer> i5 = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5)); // Arrays.asList()
import java.util.ArrayList;
public class Test {
public static void main(String[] args) {
ArrayList<String> colors = new ArrayList<>();
// ๊ฐ ์ถ๊ฐ add()
colors.add("Black");
colors.add("White");
colors.add(0, "Green"); // index ์ง์ , ํด๋น index์ ๊ฐ ์ถ๊ฐ, ๊ทธ ๋ค index์ ๊ฐ์ 1์นธ ๋ฐ๋ฆผ
// ๊ฐ ๋ณ๊ฒฝ set()
colors.set(0, "Blue");
System.out.println(colors); // [Blue, Black, White]
// ๊ฐ ์ญ์ remove()
String removedColor = colors.remove(0); // index๋ก ์ญ์
colors.remove("White"); // ๊ฐ์ผ๋ก ์ญ์
System.out.println(colors); // [Black]
// for-each loop
for (String color : colors) {
System.out.print(color + " ");
}
// for loop
for (int i = 0; i < colors.size(); ++i) {
System.out.print(colors.get(i) + " ");
}
// iterator ์ฌ์ฉ
Iterator<String> iterator = colors.iterator();
while (iterator.hasNext()) {
System.out.print(iterator.next() + " ");
}
}
}
๐ง ํ๊ณ

์, ์ ๋ง์ ๋ง ํผ๊ณคํ ํ์ฃผ์๋ค.
๋์ ์ฒด๋ ฅ์ ํ๊ณ๋ฅผ ๋๋ ๊ธฐ๋ถ์ด๋๊น?
๊ฑด๊ฐ ๊ด๋ฆฌ์ ์ค์์ฑ, ์ด๋์ ์ค์์ฑ์ ๋๊ผ๋ค. ์ทจ์ ํ๋ฉด ์ด๋ํด์ผ๊ฒ์,,,
์๋ก์ด๊ฑฐ(?)๋ฅผ ๋ฐฐ์ฐ๋ ๊ธฐ๋ถ์ ์ธ์ ๋ ์กฐ๊ธ ์ง๋ฆฟํ๋ค! 2ํ๋ ์ด ๋ง์ง๋ง์ด๊ณ ๊ธฐ์ต ํ๋๋ ์๋๋๊น ์๋ก์ด๊ฑฐ ๋ง์ง
์๋ฐ๋ ์ ๋ง ๋งค๋ ฅ์ ์ธ(?) ์ธ์ด๋ผ๊ณ ์ด์ ์กฐ๊ธ ๋๊ปด์ง๋ค. ๊ฐ์ฌ๋์ด ์ ๋ง ์ ๊ฐ๋ฅด์ณ์ฃผ์ ๋ค. (๊ต์๋ ์ฃ์กํด์)
์ผ๋ฅธ ์๋ก์ด๊ฒ๋ ๋ฐฐ์ฐ๊ณ ํ๋ก์ ํธ ํด๋ณด๊ณ ์ถ๋ค! ใ ....
๐๐ป 2์ฃผ์ฐจ ๊ณํ
- ๋ฉด์ ์ ๋ณด๊ธฐ
- ์ค์ตํ๊ฑฐ ๊น์ ์ฌ๋ฆฌ๊ธฐ
- ๋งฅ๋ถ์ ์๋ฐ ํ๊ฒฝ์ค์ ํ๊ธฐ
- ์๊ณ ๋ฆฌ์ฆ ๋ฌธ์ ๋งค์ผ๋งค์ผ ํ๊ธฐ
- ์์ ๋๋๊ณ ๊ณต๋ถํ๋ค ์ง ๊ฐ๊ธฐ
- ์์นจ ์ฑ๊ฒจ๋จน๊ณ ๊ฐ์ ์๋จน๊ธฐ
- CS ๊ณต๋ถ ์์ํ๊ธฐ
'์ฐ๋ฆฌFISA' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ ์ฐ๋ฆฌ FISA ํด๋ผ์ฐ๋์์ง๋์ด๋ง 3์ฃผ์ฐจ ๊ธฐ๋ก (0) | 2023.12.09 |
---|---|
๐ ์ฐ๋ฆฌ FISA ํด๋ผ์ฐ๋์์ง๋์ด๋ง 2์ฃผ์ฐจ ๊ธฐ๋ก (1) | 2023.12.03 |