분류 전체보기

    Java 우선순위 큐, Priority Queue

    컬렉션들 list, map, set ... 난 집어넣고 바로 최댓값이나 최솟값을 뽑아내는 그런 간편한게 필요한데..? 싶으면 우선순위 큐를 사용하면 된다. 힙을 이용하여 구현이 되어있다. 123456789101112131415161718192021222324252627282930313233343536 static class xy implements Comparable{ String x; int y=0; xy(String x, int y) { this.x = x; this.y = y; } @Override public int compareTo(xy o) { if(this.y>o.y) return 1; else return -1; } } public static void main(String[] args) ..

    Java 형변환 정리

    1234567891011121314151617181920212223242526272829303132333435363738394041 // Int to String int a=30; String b= Integer.toString(a); // String to Int String a="300"; Int b=Integer.parseInt(a); // Char to Int char a='3'; int b=Character.getNumericValue(a); int c=a-'0'; // Int to Char int a=3; char b= (char)(a+'0'); int a =10; char c='A'; System.out.println((char)('A'+a-10));cs

    Set 에 대하여

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 HashSet set=new HashSet(); set.add(1); //추가 set.remove(1); //삭제 set.clear(); //비우기 set.contains(1); //해당 값 포함하는지 확인 set.size(); //크기 구하기 set.isEmpty(); //비어있는지 확인 Iterator it=set.iterator(); //iterator로 값 while(it.hasNext()){ int value=it.next(); sout(value); //1 } for(Integer tmp:set){ system.out.println(tmp); } //이것도 된다. //set에다가 새로운 set합칠 때에 사용 ..

    Java 조합과 순열

    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 29 30 31 32 public class test{ public static void main(String[] args) { int[] arr = {1, 3, 5, 7, 9}; boolean[] visit = new boolean[5]; combination(visit, 5, 3, 0, arr); } private static void combination(boolean[] visit, int n, int r, int start, int[] arr) { if (r == 0) { for (int i = 0; i

    2020 카카오 블라인드 프로그래머스 - 길 찾기 게임

    https://programmers.co.kr/learn/courses/30/lessons/42892 코딩테스트 연습 - 길 찾기 게임 [[5,3],[11,5],[13,3],[3,5],[6,1],[1,3],[8,6],[7,2],[2,2]] [[7,4,6,9,1,8,5,2,3],[9,6,5,8,1,4,3,2,7]] programmers.co.kr 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 ..

    ENUM 에 대해 알아보자

    enum Animal{ RABBIT, CAMEL, TIGER } 이것들은 class Animal{ public static final animal RABBIT= new animal(); public static final animal CAMEL= new animal(); public static final animal TIGER= new animal(); private animal(){} } 와 같다. 상수타입을 자바5 버전에 들어서 enum을 추가한 것이다. 생성자가 private이다. 이것은 클래스 animal를 인스턴스화 하지 못하게끔 의도한 것이다. enum은 클래스이기 때문에 생성자를 가질 수 있다. enum Animal{ RABBIT, CAMEL, TIGER; Animal(){ System.o..

    스프링 시큐리티 denied Page 404 뜨는 이유

    원래라면 accessDeniedPage는 403 에러가 떠야하는데, 404에러가 뜰 때가 있다. 이 때에는 큰 착각을 했을 것이다. .exceptionHandling().acce4ssDeniedPage("/user_denied") 이렇게 해두면 usr_denied.html 로 가는게 아니라 저곳으로 get 보내기 때문에 착각하지말자 컨트롤러에 @GetMapping("/user_denied") 해놓고 return 으로 적절한 html 로 보내자. 이것을 찾지못하고 있기 때문에 404 에러가 뜨게된다.

    Spring Data JPA, Querydsl 조금 정리

    Spring Data JPA, Querydsl 조금 정리

    스프링 데이터 JPA 조회 결과가 많거나 없으면 List findByUsername(String name); //컬렉션 Member findByUsername(String name); //단건 Optional findByUsername(String name);; //단건 Optional 컬렉션: 결과 없음: 빈 컬렉션 반환 단건 조회: 결과 없음: null 반환 결과가 2건 이상: javax.persistence.NonUniqueResultException 예외 발생 * 단건으로 지정한 메서드를 호출 시에 JPQL의 Query.getSingleResult() 메서드를 호출하는데, 이 메서드를 호출했을 때 조회 결과가 없으면 javax.persistence.NoResultException 예외가 발생하게 ..