1부터 n까지 루프 없이 출력해라package recur;public class test { public static void main(String[] args) { int n = 10; printNos(n); } public static void printNos(int n) { if(n>0) { printNos(n-1); } System.out.print(n + " "); } } 별도의 메서드로 분리해 자신의 메서드(public static void printNos(int n))를 계속 호출함 만약에 integer였다면 정수형태라고 표현했더라도 객체이다. n에 있는 주소값이 같이 만들어진다. 이거를 copy of reference (copy를 pass라고도 한다. pass by) 이동..
Comparable: 비교할 수 있는Comparator: 비교자package generic;import java.awt.Button;import java.util.ArrayList;import java.util.Comparator;public class Test { public static void main(String[] args) { int []arr1= {1,2,3}; // homogeneous collection String []arr2= {"hello","hi","bye"};// homogeneous collection Object []arr3= new Object[3];//heterogeneous collection arr3[0]="hello"; arr3[1]=new Test(); ..
인터페이스는 계열에 가깝다. String (Java Platform SE 8 ) String (Java Platform SE 8 )Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argumdocs.oracle.com Serializable계열 clien..
실제 분야에서는 공간복잡도가 중요한 경우가 다수있다.자바는 타입을 항상 앞에 둔다. String[] cars; 배열 2가지 타입- primitive: 숫자 단위 논리 8개 - reference: 위의 8개의 제외한 나머지들, class, intereface, enum, [ ]배열자체가 reference데이터고 instance(객체)영역에 있다. (이름 옆에 값이 못온다.)package array;public class Test { public static void main(String[] args) { // 배열도 참조 데이터 형태이다. // 선언 = 생성 {초기화} String[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; //할당 연산자가 없어 이름만 저장 Sy..
자바에서는 ;(세미콜론) 완전 필수에러 메시지는 많이 읽어보는게 좋다. package com.ysh.basic; import java.sql.Date; public class MyProfile{ public static void main(String[] args ) { int age = 30; double tall = 160.5; char gender = '여'; boolean isPretty = true; MyStr name = new MyStr(); // MyDate birthday = new MyDate(); // String name = new String("양세현"); Date birthday = new Date(2001, 10, 3); ..
Java의 목표 (개발자 편의성)1. WORA(write one run away) 여기까지 개발과정 | 인터프리팅.java(source code) ---compile---> .class(byte code) ------ 실시간 코드 변환 ---------> 🖥️ 중간 단계 코드 ------- 실시간 코드 변환 ---------> 🖥️ ..
TS 상속인터페이스는 키워드를 통해 클래스가 따라야 하는 유형을 정의하는데 사용인터페이스: 복합적 구조를 나타내기 위해 사용된다.// 인터페이스 이름: Shape// 인터페이스: 복합적 데이터 단위, 이름만으로 가치가 있다.// 인터페이스를 잘 만들어야 좋다// return 타입이 number이다.interface Shape {// getArea의 파라미터는 없고 return 타입은 number getArea: () => number;}// interface의 상속(구현은) implements이다. // Rectangle클래스가 두개 이상의 인터페이스(Shape, A) 구현방법class Rectangle implements Shape { public constructor(protected readon..
forEach()-> 개별 처리, 각개 전투!index의 개수만큼 호출이 된다.const numbers = [45, 4, 9, 16, 25];let txt = "";numbers.forEach(myFunction);function myFunction(value) { txt += value + "";} 처리한 결과에 대한 return이 없다. map()const numbers1 = [45, 4, 9, 16, 25];const numbers2 = numbers1.map(myFunction);function myFunction(value, index, array) { return value * 2;}forEach의 경우 numbers2가 없는데 map의 경우 const numbers가 있다. 처리한 결과에..
JavaScript Window - The Browser Object Modelbrower object model - 브라우저에 내장되어 있다.기본적인 객체는 window객체이다. window는 최상위 객체이다. 종류widow.screenwindow.location: 이동하는데 쓰인다. window.location.href 현재 페이지의 href(URL)을 반환window.location.hostname웹 호스트의 도메인 이름을 반환window.location.pathname현재 페이지의 경로와 파일 이름을 반환window.location.protocol 사용된 웹 프로토콜(http: 또는 https:)을 반환 윈도우의 기본 포트 HTTP의 경우 80, 보안 웹인 HTTPS의 경우 443window.l..
⭐ var, let 그리고 const 차이점 ⭐범위재선언재할당호이스팅 this 바인딩varxooolet oxoxconst oxxx 뭐가 좋냐? 봄이 좋냐?let과 const는 블록 스코프를 갖는다. (해당 블록안에서만 유효하다.)let과 const는 재선언 불가능하다.let과 const는 선언 전에 사용할 수 없다.let과 const는 this에 바인딩되지 않는다. (객체의 this 키워드와 연결되지 않는다.)let과 const는 호이스팅되지 않는다.바로 선언한 블록은 글로벌 스퍽을 갖는다? 스코프{ // 글로벌 변수로 선언됨됨 var aa = 100;}// 소괄호를 갖으면 전부 function이다. {} var는 무조건 글로벌 스코프갖는다. 글로벌 스코프란?코드 전체에서 접근 가능한 범위를 의미한..