현실을 넘어
close
프로필 배경
프로필 로고

현실을 넘어

  • 분류 전체보기
    • 자바
      • 일반
      • 알고리즘
      • 객사오
      • 스프링입문객체지향
      • 리팩토링
      • 스프링부트3
      • JPA
      • QueryDsl
      • Spring Security
    • 코틀린
      • 코틀린인액션
      • 알고리즘
    • 일 관련 삽질
    • JIRA
    • 도메인주도개발
    • DB
      • Mysql
    • MQ
      • Apache Kafka
    • Docker-Kubernetes
    • GITHUB
    • REST API
    • 리눅스
  • 홈
  • 태그
  • 방명록

리스트의 요소가 단일값인 경우 Collections.singletonList 를 사용해야하는 이유

개요인터넷을 돌아다니던 도중.. 리스트에 단일한 객체만 들어가는 경우 Collection.singletonList() 를 사용하는 것이 좋다는 글을 보았다.테스트 코드인 경우 유용함 - 실 비즈니스 로직엔 싱글톤보단 단순 리스트 사용하는 게 확장에 유리하기에.. 실제로 GPT 도 싱글톤 리스트를 추천하는 것을 보았다.왜 싱글톤 리스트를 단일값인 경우 사용하는 거지?일단 장점이 몇가지 있다.불변성Collections.singletonList 는 불변 리스트를 생성한다.해당 리스트는 단 하나의 요소만 포함되고, 생성 후에는 해당 요소를 추가하거나 제거할 수 없다!메모리 효율사실 정말 미미한 정도라 의미가 있나 싶지만…테스트 코드는 최대한 가벼워야한다고 생각한다!내부적으로 단일 요소만을 저장하기에, 메모리 사..

  • format_list_bulleted 자바/리팩토링
  • · 2024. 2. 19.
  • textsms

[팁] compareTo 기준점

compareTo 기준 어느 쪽을 기준으로 정렬되는 건지 알기 어려울때..두 사람의 키 를 비교하는 것과 비슷하다.1. 첫번 째 사람의 키가 더 크다면compareTo 의 결과 양수키 큰놈이 더 뒤로 간다.2. 두 사람의 키가 동일comapreTo 결과 03. 첫 번째 사람의 키가 더 작다면compareTo 결과 음수 키 작은 놈이 앞으로 온다. Uploaded by N2T

  • format_list_bulleted 자바/일반
  • · 2024. 2. 19.
  • textsms

[Security] PasswordEncoder..?

@Bean public PasswordEncoder passwordEncoder() { return PasswordEncoderFactories.createDelegatingPasswordEncoder(); }PasswordEncoder 빈 주입return new BCryptPasswordEncoder(); -> return PasswordEncoderFactories.createDelegatingPasswordEncoder();으로 변경하였다.Password Storage :: Spring SecuritySpring Security’s PasswordEncoder interface is used to perform a one-way transformation of a password to let the..

  • format_list_bulleted 자바/Spring Security
  • · 2024. 1. 19.
  • textsms

[프로그래머스] 행렬의 덧셈 (Java)

package org.example.알고리즘.행렬의덧셈; import java.util.Arrays; /**/ class Solution { public static void main(String[] args) { Solution solution = new Solution(); System.out.println(Arrays.deepToString(solution.solution(new int[][]{{1, 2}, {2, 3}}, new int[][]{{3, 4}, {5, 6}}))); } public int[][] solution(int[][] arr1, int[][] arr2) { ArrayClass arrayClass1 = new ArrayClass(arr1); ArrayClass arrayClass..

  • format_list_bulleted 자바/알고리즘
  • · 2024. 1. 14.
  • textsms

[일반] Interger.valueOf 와 Interger.parseInt 의 차이점

개요Integer.valueOf와 Integer.parseInt 두 메서드는 모두 문자열을 정수로 변환하는 역할을 한다.다만, 사용 방식과 반환 값, 그리고 성능 면에서 몇 가지 차이점이 있다.반환 타입Interger.valueOfInterger 객체를 반환함Integer.parseInt기본 데이터 타입 int 를 반환캐싱Interger.valueOf-128 ~ 127 까지의 정수에 대한 Interger 객체는 캐싱되어있음같은 숫자를 요청하는 경우 캐싱된 객체를 반환하여 메모리 효율성 증대진짜 미미할듯 ㅋInteger.parseInt캐싱 X 근데 기본타입이라 캐싱의 의미가 없음.사용용도Interger.valueOf객체가 반환타입으로 필요한 경우캐싱의 이점을 누리는 경우Integer.parseInt정수 값..

  • format_list_bulleted 자바/일반
  • · 2023. 9. 12.
  • textsms
  • navigate_before
  • 1
  • navigate_next
공지사항
  • ㅇ
전체 카테고리
  • 분류 전체보기
    • 자바
      • 일반
      • 알고리즘
      • 객사오
      • 스프링입문객체지향
      • 리팩토링
      • 스프링부트3
      • JPA
      • QueryDsl
      • Spring Security
    • 코틀린
      • 코틀린인액션
      • 알고리즘
    • 일 관련 삽질
    • JIRA
    • 도메인주도개발
    • DB
      • Mysql
    • MQ
      • Apache Kafka
    • Docker-Kubernetes
    • GITHUB
    • REST API
    • 리눅스
최근 글
인기 글
최근 댓글
태그
  • #객체지향
  • #자바
  • #JPA
  • #Kotlin
  • #ddd
  • #도메인주도개발
  • #리팩토링
  • #알고리즘
  • #객사오
  • #QueryDSL
전체 방문자
오늘
어제
전체
Copyright © 쭈미로운 생활 All rights reserved.
Designed by JJuum

티스토리툴바