본문 바로가기

반응형

분류 전체보기

(347)
java 제네릭 package org.opentutorials.javatutorials.generic; class Person{ public T info; } public class GenericDemo { public static void main (String[] args) { Person p1 = new Person(); Person p2 = new Person(); } }
ArrayList<datatype> al = new ArrayList<datatype>(); package org.opentutorials.javatutorials.collection; import java.util.ArrayList; public class ArrayListDemo { public static void main(String[] args) { String[] arrayObj = new String[2]; arrayObj[0] = "one"; arrayObj[1] = "two"; // arrayObj[2] = "one"; 오류 발생 for(int i=0; i < arrayObj.length; i++) { System.out.println(arrayObj[i]); } // ArrayList al = new ArrayList(); // ArrayList의 데이터타입을 이렇게 정해둘 수..
It takes a long time to ripen. I have studied java basic grammar for almost 12 hours today, have learned many new concepts but it doesn't mean I can use it to program anything. I tried to solve a basic java algorithm problem but I couldn't even get close to the answer. I was too far away and needed even more new concepts to solve it. I will practice all the 100 java algorithm problems and make sure I can come up with answers ..
알고리즘 개념 알고리즘 정의 알고리즘이란 어떠한 문제를 해결하기 위한 여러 동작들의 모임이다. 알고리즘의 조건 알고리즘은 다음의 조건을 만족해야 한다. 입력 : 외부에서 제공되는 자료가 0개 이상 존재한다. 출력 : 적어도 2개 이상의 서로 다른 결과를 내어야 한다.(즉 모든 입력에 하나의 출력이 나오면 안됨) 명확성 : 수행 과정은 명확하고 모호하지 않은 명령어로 구성되어야 한다. 유한성(종결성) : 유한 번의 명령어를 수행 후(유한 시간 내)에 종료한다. 효율성 : 모든 과정은 명백하게 실행 가능(검증 가능)한 것이어야 한다. 알고리즘의 구현 단계 문제 정의 → 모델 고안 → 명세 작성 → 설계 → 검증 → 분석 (복잡도 등) → 구현 → 테스트 → 문서화 알고리즘 예시 다음은 가장 큰 숫자를 찾는 알고리즘이다. ..
overriding의 조건 package org.opentutorials.javatutorials.overriding.example1; class Calculator { int left, right; public void setOprands(int left, int right) { this.left = left; this.right = right; } public void sum() { System.out.println(this.left + this.right); } public void avg() { System.out.println((this.left + this.right) / 2); } } class SubstractionableCalculator extends Calculator { public void sum() { S..
상속과 생성자 (기본생성자와 super) package org.opentutorials.javatutorials.Inheritance.example3; class Calculator { int left, right; // "여기" // 기본생성자를 명시적으로 선언해줘야 한다. // public Calculator(){} public Calculator(int left, int right){ this.left = left; this.right = right; } public void setOprands(int left, int right) { this.left = left; this.right = right; } public void sum() { System.out.println(this.left + this.right); } public vo..
extends 상속 package org.opentutorials.javatutorials.Inheritance.example1; class Calculator { int left, right; public void setOprands(int left, int right) { this.left = left; this.right = right; } public void sum() { System.out.println(this.left + this.right); } public void avg() { System.out.println((this.left + this.right) / 2); } } class SubstractionableCalculator extends Calculator { public void substrac..
자바 생성자 package org.opentutorials.javatutorials.constructor; class Calculator { int left, right; // 생성자 constructor // 생성자의 이름은 클래스의 이름과 같다. // 생성자는 어떤 메소드보다 가장 먼저 작동한다. // 자바는 생성자가 없으면 클라스와 동일한 생성자를 만들어 작동한다. public Calculator(int left, int right) { this.left = left; this.right = right; } public void sum() { System.out.println(this.left + this.right); } public void avg() { System.out.println((this.left..

반응형