Skip to content

Instantly share code, notes, and snippets.

@Bogyie
Created February 9, 2022 07:21
Show Gist options
  • Save Bogyie/c9a5e8b680b2700516a512392ea06226 to your computer and use it in GitHub Desktop.
Save Bogyie/c9a5e8b680b2700516a512392ea06226 to your computer and use it in GitHub Desktop.
[Java] 객체 vs 인스턴스
// 클래스 : 객체를 대표하는 이름(Type)
class Polygon {
int edge;
int vertex;
void Polygon(int edge, int vertex) {
this.edge = edge;
this.vertex = vertex;
}
}
class Main {
static void main(String[] args) {
Polygon triangle; // 객체 : 구현해야 할 대상, 메모리에 적재되지 않음
triangle = new Polygon(3, 3); // 인스턴스 : 구현된 실체, 메모리에 적재됨
// Polygon:객체 정의 triangle:객체명 정의 = new Polygon():인스턴스;
// -> Polygon triangle = new Polygon();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment