Iterator 인터페이스 자바의 컬렉션 프레임워크는 컬렉션에 저장된 요소를 읽어오는 방법을 Iterator 인터페이스로 표준화하고 있다. Collection 인터페이스를 상속받은 List와 Set 인터페이스에서 iterator() 메소드를 사용할 수 있다. Iterator 인터페이스 메소드 boolean hasNext() : 해당 iteration이 다음 요소를 가지고 있으면 true를 반환하고, 더 이상 다음 요소를 가지고 있지 않으면 false를 반환한다. E next() : iteration의 다음 요소를 반환한다. default void remove() : 해당 iterator로 반환되는 요소를 현재 컬렉션에서 제거한다. ArrayList arrList = new ArrayList(); arrL..
Arrays 주요 메소드 Arrays.asList(array) : List 타입으로 변환 Arrays.equals(array1, array2) : 두 배열이 일치하는지 검사 Arrays.sort(array) : arr을 오름차순으로 정렬 String[] arr1 = {"A", "B", "C"}; String[] arr2 = {"D", "E", "F"}; System.out.println(Arrays.toString(arr1));//[A, B, C] //Arrays.asList(array) List arrlist = Arrays.asList(arr1); System.out.println(arrlist);//[A, B, C] //Arrays.equals(array1, array2) System.out.pri..
조건문 - if문 if 조건식: 수행문 조건식을 다 적은 후에 콜론(:)을 적어서 조건식이 끝났음을 파이썬 인터프리터에게 알린다. 조건을 만족했을 때 실행할 문장은 if문 다음 라인에 탭 또는 스페이스로 들여 쓰기 후 적는다. 소스코드 bitcoin = 8400000 if bitcoin > 10000000: print("bitcoin 매수") - if/else if 조건: 문장 1 else: 문장 2 조건이 참일 때는 문장1이 수행되고 조건이 거짓일 때는 문장2가 수행된다. 소스코드 bitcoin = 1000 if bitcoin >= 1000: print("bitcoin 1000 돌파") else: print("bitcoin 1000 미만") - if/elif/else if 조건 1: 조건 1이 참일 때..
변수 파이썬에서 변수는 영어 소문자를 사용하면 된다. #변수 선언 bitcoin = 9751500 9751500 값은 사용자의 PC 메모리 어딘가에 위치하고 이 값은 메모리상에서 고유의 주소를 갖게 된다. bitcoin이란 변수가 메모리상에 어떤 번지에 있는 9751500 값을 가리키는 것을 바인딩(binding)이라 한다. 9751500 * 3 bitcoin * 3 변수를 사용하면 값을 직접 사용하지 않고 표현할 수 있고 코드의 의미를 더 쉽게 파악할 수 있다. 문자열 파이썬은 문자('A')와 문자열("ABC")을 구분하지 않고 모두 문자열이라고 한다. 'hello world' "hello world" "I'd love to change the world" "3" 위 네 가지 표현 모두 문자열에 해당한..
1. 파이썬 설치 - python.org에서 설치 파일 다운로드 - 설치 페이지에서 Add Python 3.xxx to PATH 체크박스를 체크 후 설치 2. 파이썬 버전 및 설치 확인 - cmd > "python -V" 입력 3. 프로젝트 폴더로 이동 - cmd에서 cd 명령을 사용해서 테스트할 프로젝트가 있는 폴더로 이동 4. 서버 구동하기 - 파이썬 버전이 3.X인 경우 : python -m http.server - 파이썬 버전이 2.X인 경우 : python -m SimpleHTTPServer - 8000 포트가 아닌 다른 포트에서 실행하려면 python -m http.server 7800과 같이 포트번호 입력 5. 서버 접속 - 웹브라우저에 "localhost:8000"을 입력하면 서버로 이동 ..
정규표현식(regular expression) 정규 표현식은 문자열에 나타나는 특정 문자 조합과 대응시키기 위해 사용되는 패턴입니다. 자바스크립트에서 정규 표현식 또한 객체입니다. 사용 예 이메일, 주소, 전화번호 규칙 검증 textarea에 입력된 것 중 불필요한 입력값 추출 트랜스파일링 개발 도구에서의 문자열 치환 정규표현식 선언 1. 리터럴 let re = /abc/; 2. 생성자 함수 let re = new RegExp("abc"); 메소드 1. match() 문자열이 정규식과 매치되는 부분을 검색 문법 : str.match(regexp) 결과 값 : 문자열이 정규식과 일치하면, 결과 정보를 담은 Array를 반환하고 아니면 null을 반환 ex) [ '32', index: 3, input: 'a..
생성자패턴 객체지향적인 방법으로 객체에서 비슷한 속성과 행위를 묶어서 표현할 수 있다. 객체를 동적으로 생성해서 중복을 줄일 수 있다. prototype에 메서드를 속성으로 추가할 수 있다. 객체리터럴(Object literal) 코드의 중복이 발생한다. var healthObj = { name : "seogineer", lastTime : "PM 10:12", showHealth : function(){ console.log(this.name + "님, 오늘은 " + this.lastTime + "에 운동을 하셨네요."); } } var healthObj2 = { name : "crong", lastTime : "AM 09:10", showHealth : function(){ console.log(th..
1. pom.xml에서 JDK와 Servlet의 버전을 각각 1.8과 3.1.0으로 변경 후 저장한 다음 "프로젝트 우클릭 → Maven → Update Project..." UTF-8 1.8 1.8 javax.servlet javax.servlet-api 3.1.0 provided 2. web.xml에 DTD를 3.1로 변경한다. Archetype Created Web Application index.html index.jsp 3. 이클립스 Navigator 뷰에서 프로젝트/.settings/org.elclipse.wst.common.project.facet.core.xml 파일을 수정한다. 4. 이클립스 restart
const, let은 자바스크립트 ES6(ECMA 2015)부터 생긴 구문이다. 익스플로러 호환성 문제 때문에 아직도 대다수 웹에서는 var 변수만 사용된다. const 선언할 때 바로 값을 넣어줘야 한다. 한번 넣은 값은 바꿀 수 없는 상수이다. const mouse_1 = '서울쥐'; mouse_1 = '귀촌쥐';//Error let 선언과 값 정의를 따로 할 수 있다. 넣은 값은 이후 얼마든 바꿀 수 있다. 대신 선언을 다시 할 수 없다. let mouse_2; mouse_2 = '시골쥐'; mouse_2 = '상경쥐'; let mouse_2 = '서울쥐';//Error var 값을 자유롭게 변경할 수 있다. 다시 선언할 수 있다. var mouse_3 = '청계천쥐'; mouse_3 = '잠적쥐'..