본문 바로가기
728x90

Java8

Ubuntu Java 11 설치 (Open JDK) https://codechacha.com/ko/ubuntu-install-open-jdk11/ Ubuntu 20.04 - OpenJDK 11 설치, 삭제 Ubuntu 20.04에 OpenJdk 11을 설치하는 방법을 소개합니다. apt 명령어로 쉽게 설치할 수 있습니다. 만약 apt로 설치할 수 없다면 설치 파일을 다운로드하여 직접 설치하는 방법이 있습니다. 두가지 방법 codechacha.com 2022. 4. 10.
5주차 모음사전 (자바) package prog; public class 오주차_모음사전 { public static void main(String[] args) { Solution_모음사전 s= new Solution_모음사전(); // System.out.println(s.solution("AAAAE")); // System.out.println(s.solution("AAAE")); System.out.println(s.solution("I")); // System.out.println(s.solution("EIO")); } } class Solution_모음사전{ static char[] M = new char[]{'A', 'E', 'I', 'O', 'U'}; static int count=0; static boolean .. 2021. 9. 14.
124 나라의 숫자 (자바) package prog; public class 일이사_나라의_숫자 { public static void main(String[] args) { 일이사_나라의_숫자_Solution s= new 일이사_나라의_숫자_Solution(); System.out.println(s.solution(1)); System.out.println(s.solution(2)); System.out.println(s.solution(3)); System.out.println(s.solution(4)); } } class 일이사_나라의_숫자_Solution{ public String solution(int n) { StringBuilder answer = new StringBuilder(); while(n!=0){ if(n%3!.. 2021. 9. 6.
최대 공약수 public static int gcd(int a, int b) { while(b!=0){ int r = a%b; a= b; b= r; } return a; } 2021. 9. 5.
2주차 package prog; public class 이주차 { public static void main(String[] args) { Solution s = new Solution(); //System.out.println(s.solution(new int[][] {{100,90,98,88,65},{50,45,99,85,77},{47,88,95,80,67},{61,57,100,80,65},{24,90,94,75,65}})); System.out.println(s.solution(new int[][] {{70,49,90},{68,50,38},{73,31,100}})); } } class Solution { public String solution(int[][] scores) { String answer = .. 2021. 8. 31.
프로그래머스 거리두기 확인하기 package prog; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; public class 거리두기_확인하기 { public static void main(String[] args) { Solution s = new Solution(); int[] answer =s.solution(new String[][] { {"POOOP", "OXXOX", "OPXPX", "OOXOX", "POXXP"}, {"POOPX", "OXPXP", "PXXXO", "OXXXO", "OOOPP"}, {"PXOPX", "OXOXP", "OXPOX", "OXXOP", "PXPOX"}, {"OOOXX", "XOOOX", "OOOXX", .. 2021. 8. 30.
자바 sort (Compareable, Comparator, lambda) 백준 1181 단어 정렬 우리가 해야할 것은 단어 정렬이니 기본적으로 정렬할 배열의 타입은 String 이 될 것이다. 즉 T 는 String 이 된다는 것이다. 이렇게 Comparator 의 타입을 넣었으면, 다음으로 해야할 것은 compare 메소드를 오버라이딩하는 것이다. 즉, 아래 코드가 기본형이 되겠다. String[] arr = new String[N];// 배열에 단어가 이미 초기화 되었다고 가정 Arrays.sort(arr, new Comparator() { @Override public int compare(String s1, String s2) { /* 정렬방법 구현 */ } }); 기본적으로 양수일경우 Arrays.sort()에서 정렬 알고리즘에 의해 위치를 바꾸고, 0 이나 음의 정.. 2021. 8. 6.
자바 조합 생성 import java.util.Arrays; public class Comb { static int N=5,R=2; static int[] input= {1,5,7,8,9}; static int[] numbers=new int[R]; public static void main(String[] args) { comb(0,0); } public static void comb(int cnt, int start) { if(cnt==R) { System.out.println(Arrays.toString(numbers)); return; } for(int i = start;i 2021. 8. 3.
728x90