분류 전체보기 62

[JAVA] 풀스택 개발자 부트캠프 012일차 ③ static

static : 정적  동적(dynamic) stack   heap    static  system            opublic class MainClass { public static void main(String[] args) {// MyClass cls = new MyClass();// cls.number = 123;// cls.method();// MyClass.static_number = 111; //객체를 생성하지 않아도 변수를 생설할 수 있는 것이 static 변수 //멤버변수, static 넘버는 따로 초기화하지 않아도 0이다./* MyClass cls = new MyClass(); ..

[JAVA] 풀스택 개발자 부트캠프 012일차 ② final

final 제약 변수, 메소드, 클래스에서 사용 가능public class MainClass { public static void main(String[] args) { /* final : 제약 변수, 클래스, 메소드에 전부 적용할 수 있음. */ // 변수의 자료형 앞에 final을 붙여 사용하면 변수가 상수가 됨. int num = 10; num = 20; // 변수는 값 변경이 됨. final int number = 10; // 변수가 아닌 상수(변하지 않는 값)가 됨. // number = 20; = MIN){ } String s..

[JAVA] 풀스택 개발자 부트캠프 011일차 ④ 상속 예제 3개

1. 다음과 같은 실행결과를 얻도록 Point3D클래스의 equals()를 멤버변수인 x, y, z 의 값을 비교하도록 오버라이딩하고,  toString()은 실행결과를 참고해서 적절히 오버라이딩하시오. [실행결과] [1,2,3] [1,2,3] p1==p2 ? false p1.equals(p2) ? true Point3D p1 = new Point3D(1, 2, 3);Point3D p2 = new Point3D(1, 2, 3);System.out.println(p1.toString());System.out.println(p2.toString());System.out.println("p1 == p2?"+ (p1 == p2));System.out.println("p1.equals( p2 )?"+ ( p1.e..

[JAVA] 풀스택 개발자 부트캠프 011일차 ③ 달력(Calendar)

Calendar    year month day             Date        timeimport java.nio.channels.CancelledKeyException;import java.util.Calendar;import java.util.GregorianCalendar;public class MainClass { public static void main(String[] args) { Calendar cal = Calendar.getInstance(); // 날짜 getter int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; // 0 ~ ..

[JAVA] 풀스택 개발자 부트캠프 011일차 ② protected, over ride, super

protected (외부로부터)보호하다 자식클래스에서는 접근이 가능하지만 외부에서 접근은 안됨 Over Ride 상속 받은 클래스에서 고쳐(추가, 보강) 기입 super 부모 클래스를 가리키는 주소(pointer)main.MainClasspackage main;import cls.Child;import cls.Parent;public class MainClass { public static void main(String[] args) { Parent parent = new Child(); parent.method(); parent.setName(""); }}cls.Parentpackage cls;public class Parent { protected..

[JAVA] 풀스택 개발자 부트캠프 011일차 ① 상속성

상속성 inheritance- 부모 클래스로부터 속성 or 특성을 상속받는 것 - variable(변수) method(함수)를 물려 받는 것 - 다중 상속은 불가능하다 형식: class 부모클래스명{     부모변수     부모메소드 } class 자식클래스 extends 부모클래스명{     (부모변수)     (부모메소드)     자식변수     자식메소드public class MainClass { public static void main(String[] args) { Child child = new Child(); child.number = 123; child.name = "홍길동"; child.parent_method(); }}clas..