2018년 10월 15일 월요일

자바 정리 배열, 다형성

배열

int[] a,b[] -> a는 1차 , b는 2차

  final int SIZE = arr.length;   
  -> 상수로 지정해서 for문 돌릴때  .length를 계속 참조하지 않게함

  for(int i :arr) {                  
  -> 조회할때만 가능, 배열 원소 값을 바꾸는건 무의미(참조값을 복사해온다)
   System.out.println(arr[i]);                       배열의 값은 바꿀수있음
  }


public static  void printArray(int[] arr)
-> static이 없으면 instance 메소드기 때문에 객체 생성 후 메모리 등록하고 실행해야함

person p[] = new person[3];  //배열객체 생성 , person 객체를 생성한게 아님
person ppp[] = new person[] { new person(),new person(),p};

  int [] aTeam = new int[] {120,100,90,80};
  int [] bTeam = new int[] {100,100,90};
  int [] teams[] = new int[2][];
  teams[0] = aTeam;
  teams[1] = bTeam;

void p( int... a){}  -> 가변인자


다형성

저장공간 데이터타입 >= 값의 데이터타입  (상속이 전제조건, 트리구조로 타입의 크기를 결정)
동적바인딩
employee eg = new engineer();
eg.getInfo();   => 컴파일시 employee에서, 런타임시 engineer에서 실행
employee eg[] = new engineer[2];
ef[0] = new engineer();
ef[1] = new manager();
=> 배열로도 동적바인딩 가능

매개변수로 부모클래스로 받으면 확장성이 증가함
a개발사가 고객사 프로그램을 관리할때 상위 클래스를 구현함
고객사는 상위클래스를 상속받고 a개발사의 기능을 사용함





flutter 기본 개념 1

  Scaffold  - 화면 뼈대 역할  - 기본적으로 AppBar body floatingActionButton 같은걸 배치해줌  return Scaffold (       appBar : AppBar ( title : const Text ...