본문 바로가기

java

(8)
[JAVA] 백준 11047 동전 0 JAVA 문제풀이(feat.더러운 코드) https://www.acmicpc.net/problem/11047 11047번: 동전 0 첫째 줄에 N과 K가 주어진다. (1 ≤ N ≤ 10, 1 ≤ K ≤ 100,000,000) 둘째 줄부터 N개의 줄에 동전의 가치 Ai가 오름차순으로 주어진다. (1 ≤ Ai ≤ 1,000,000, A1 = 1, i ≥ 2인 경우에 Ai는 Ai-1의 배수) www.acmicpc.net 내가 쓴 답안(좋은 답안은 아니라고 생각됩니다) import java.util.Scanner; public class Main{ static int forMaxCount = 0; static int ordinalNum = 0; public static void main(String[] args) { Scanner sc = new Sc..
[JAVA] 백준 1427 소트인사이드 문제풀이 및 개념 정리 https://www.acmicpc.net/problem/1427 1427번: 소트인사이드 첫째 줄에 정렬하려고 하는 수 N이 주어진다. N은 1,000,000,000보다 작거나 같은 자연수이다. www.acmicpc.net 내가 쓴 답안은 아래와 같다. import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); String tempN = Integer.toString(N); int tempNLength = t..
[JAVA] BufferedReader, BufferedWriter BufferedReader / BufferedWriter란? BufferedReader와 BufferedWriter는 버퍼를 사용하여 읽기와 쓰기를 하는 함수. 버퍼를 사용하지 않은 입력은 키보드 입력이 키를 누르는 즉시 바로 프로그램에 전달된다. 버퍼를 사용하는 입력은 키보드 입력이 있을 때마다 한 문자씩 버퍼로 전송한다. 버퍼가 가득 차거나 개행 문자가 나타나면 버퍼의 내용을 한번에 프로그램에 전달한다. 둘다 기존의 Scanner와 System.out.println()보다 속도 측면에서 빠르기 때문에 많은 양의 데이터를 처리할 때 유리하다. BufferedReader / BufferedWriter 사용법 import import java.io.BufferedReader; import java.io.B..
1978 소수 찾기 (JAVA) 내가 쓴 답안 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int testCase = scanner.nextInt(); int[] numberList = new int[testCase]; for(int i = 0; i< testCase ; i++) { numberList[i] = scanner.nextInt(); } int count = 0; for(int j = 0; j < numberList.length; j++) { int trueOrFalse= isPrime(numberList[j]); if(trueOrFalse ..
[eclipse] Dynamic Web Project 만들 때 Source folder 이름이 없는 경우 해결법 Dynamic Web Project를 만드는 과정에서 Java application 환경 설정 단계에 들어왔는데 Source folder와 Default output folder명이 텅텅 비어 있어서 당황했었다. 이럴 땐 이렇게 해결하자. Source folder명을 src로 edit해주고 Defaut output folder엔 build\classes라고 써주자. 스크린샷 출처 및 상세 내용 https://carrotweb.tistory.com/14 이클립스 다이나믹 웹 프로젝트 만들기 1 - Eclipse Dynamic Web Project Dynamic Web Project(다이나믹 웹 프로젝트)는 Java Servlet(서블릿) 기반의 웹 애플리케이션입니다. ​ Servlet(서블릿)은 웹 브라우..
[안드로이드][프로젝트2]Firebase orderByChild descending 하는 법 (부제: recyclerView setReverseLayout(true)) 내가 본래 원했던 것은 firebase orderByChild를 통하여 recyclerView를 내림차순으로 정렬하는 거였다. 먼저 내가 시도했을 때 소용 없었던 방법을 소개하겠다. 1. 공식문서에 있는 내용 citiesRef.orderBy("name", Direction.DESCENDING); 이 방법은 공식문서에서 나온 내용이나 실제로 위와 같이 코드를 입력하면 작동이 안 된다. Direction에서 문제가 생겨 통하지 않는다. 출처: https://firebase.google.com/docs/firestore/query-data/order-limit-data#java_2 Cloud Firestore로 데이터 정렬 및 제한 | Firebase Documentation Join Firebase at G..
[JAVA]텍스트 추출 방법과 Int로 변형하는 방법. @FXML private TextField num1; 다음과 같이 TextField에서 데이터를 Int로 바꿀 때 다음과 같이 한다. 1. 텍스트를 먼저 추출한다. num1.getText().toString(); 2. Int로 바꾼다. - Integer.parseInt(); 이용. int result = Integer.parseInt(num1.getText().toString());
[오류일지] 1. Java - 프로젝트 새로 할 때마다 Build Path 해야지! 2022.01.26 새로운 프로젝트를 할 때마다 Build Path 해주는 걸 잊지말자! Build Path에서 mysql connector와 연결을 해야 DB연동이 되지! 순서는 프로젝트 마우스 우클릭 -> Build Path -> Configure Build Path ->Libraries ->Add External JARs -> mysql connector 파일과 연결하기! (아래 사진 참조)