students.csv id,name 1,A 2,B 3,C public class StudentInfo { private int id; private String name; public StudentInfo(int id, String name){ this.id = id; this.name = name; } public int studentId(){ return id; } @Override public String toString(){ return "Student Id: " + this.id + ", " + "name: " + this.name + "\n"; } } public class Main { public static void main(String[] args) throws FileNotFoundE..
asList() is used to convert Array to List. This example takes an Integer type array as a parameter and it needs to remove duplicate numbers as a result. But, when you use asList(), the type of array should be Object type wrappers. Because Generics only works for a reference type. List 는 Generic 이기에 오직 reference type만을 전달 받는다. 그래서 asList()에 primitive 타입이 올 수 없게 된다. Example Code import java.util.*..
enum 열거형 - enum은 연관된 상수들의 집합(a set of named constants.)으로 열거 순서에 따라 index번호를 부여받는다. - enum은 private constructor가 default이기에 public생성자의 생성이 금지된다 인스턴스를 만들 수 없다는 것은 즉, 다른 용도의 사용을 금한다는 의미이다. Example Code enum Fruit{ APPLE, PEACH, BANANA; Fruit(){ System.out.println("Constructor"); } } public class Main { public static void main(String[] args) { Fruit type = Fruit.APPLE; switch(type){ case APPLE: Sys..
예외처리 (Exception handling) 은 프로그램의 논리에 벗어난 에러인 runtime error를 발견하도록 도와준다. - 사용자정의 exception handling 이 아닌 자바에 자체적으로 내장되어있는 에러클래스의 경우 (e.g. ArithmeticException) 사용자가 새롭게 객체를 정의하지 않아도 JVM에 의해 생성된 인스턴스의 참조값이 전달된다. import java.util.Scanner; class Main{ public static void main(String[] args){ System.out.print("Enter two digits: "); Scanner keyboard = new Scanner(System.in); int num1 = keyboard.nextInt..
Upcasting을 이용하면 부모객체로 부터 상속받은 메서드를 사용할 수 있게된다. 즉, 단 하나의 부모클래스의 객체(PhoneInfo)로 여러가지 자식 메서드(univPhoneInfo, companyPhoneInfo, friendPhoneInfo)를 검색할 수 있는 장점이 있다. Example I public class PhoneInfo { String name; String phoneNum; public PhoneInfo(String name, String num){ this.name = name; phoneNum = num; } public void showInfo(){ System.out.println("name: " + name); System.out.println("phone: " + phon..
StringBuffer StringBuffer class is rewritable, unlike String class which is not allowed to change itself once it is declared. String is immutable. Methods of StringBuffer class 1. append123StringBuffer sb = new StringBuffer("Hello "); sb.append("StringBuffer"); // add new stringSystem.out.println(sb);//prints Hello StringBuffer cs 2. insert123StringBuffer sb = new StringBuffer("Hello "); sb.inse..
- Total
- Today
- Yesterday
- 프로그래머스 알고리즘문제
- string class in java
- 프로그래머스
- HashMap
- math.max
- HackerRank Algorithm
- 프로그래머스 알고리즘
- hackerrank javascript
- hackerrank
- substring()
- easy javascript algorithm
- Collection Framework
- Object type casting
- easy algorithm
- equals()
- spring boot application
- hackerrank javascript solution
- java
- 알고리즘
- C++
- algorithm
- javascript
- rest parameter
- hackerrank solution
- compareTo()
- repeat()
- math.abs
- Javascript Algorithm
- code refactoring
- ... in Javascript
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |