hashCode() and equals() - 서로 다른 객체는 각자 다른 주소값을 가지고 있기에 각자의 hashCode를 가지게 된다. - equals()는 최상위 Object class에 속해 있어서 Java Class들이 overriding 하는 것이 가능. - primitive type은 내용이 같은지 reference 는 가리키는 주소가 같은지 비교해주는데 overriding을 통해서 이 점을 수정가능. - HashSet의 equals()는 내용이 동일하면 true를 반환 - HashSet의 add()는 데이터의 입력이 가능(hashSet에 동일한 data가 존재하지 않는다)하면 true, 요소가 이미 존재하면 false를 반환 - equals() 만 overriding 할 경우 같은 내용이지만..
Singleton pattern It creates only one instance of a class, not allow to create a 2nd instance. How to create a Singleton pattern 1. Create a 'static' object of a class 2. Create private constructor to prevent that a user creates an instance with a default constructor. ※ The default constructor is called when an instance is created. the default constructor is public by default. 3. Create a 'stati..
A user types 'integer value' and 'Enter', but nextInt() does not use the end of the input, which is 'Enter' so that it leaves in the buffer. If nextLine() is used after nextInt(), the remainder causes an error. Because nextLine() is the method that reads data until the 'Enter' input. To remove the last input(Enter), simply use nextLine() to terminate the line. nextInt()메서드 다음에 nextLine()메서드가 온다면..
Simply use String.format(,) to format double output using BufferdWrite. Example output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file.getPath()), StandardCharsets.UTF_8)); output.write("Total Average: " + "\t" + "\t" + String.format("%.2f",average) + "%" + "\n" + "\n");
Decorator pattern BufferedReader sc = new BufferedReader(new FileReader("src" + File.separator + "csv_input" + File.separator + "students.csv")); We have various methods to choose for File I/O such as FileReader, BufferdReader, BufferedWriter, PrintWrite etc. The decorator pattern allows applying more than one method for File I/O without altering. File.separator File.separator enables to work on..
- Total
- Today
- Yesterday
- hackerrank
- repeat()
- math.abs
- 프로그래머스
- rest parameter
- substring()
- easy javascript algorithm
- hackerrank javascript solution
- compareTo()
- math.max
- easy algorithm
- string class in java
- Javascript Algorithm
- hackerrank solution
- equals()
- 프로그래머스 알고리즘
- code refactoring
- HackerRank Algorithm
- Object type casting
- 프로그래머스 알고리즘문제
- ... in Javascript
- Collection Framework
- HashMap
- 알고리즘
- hackerrank javascript
- spring boot application
- java
- javascript
- algorithm
- C++
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |