목록Java (21)
개발
Math.pow(a,b); //ex System.out.println(Math.pow(2,0)); //1 System.out.println(Math.pow(2,1)); //2 System.out.println(Math.pow(2,2)); //4 System.out.println(Math.pow(2,3)); //8 System.out.println(Math.pow(2,4)); //16
프로그래머스 lv1 3진법 뒤집기 3진법 직접 구현 - 재귀를 이용해 몫을 이용해 구한다. ex) 45 -> 1200 public static String makeThree(int num,String num2){ int value = num / 3; int b = num % 3; num2 = b + "" + num2; if(value == 0){ return num2; } return makeThree(value,num2); } Integer.toString 함수를 이용해 간단하게 구할 수 있다. Integer.toString(45,3); //변환할 수, n진법
public static void main( String[] args ){ int a = -1; long b = -2L; double c = -3.33; float d = -4f; System.out.println(Math.abs(a));//1 System.out.println(Math.abs(b));//2 System.out.println(Math.abs(c));//3.33 System.out.println(Math.abs(d));//4 } 양수를 반환함.
자바 풀이 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class A2596 { public static void main(String[] args) { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); try { int[][] arr = { {0,0,0,0,0,0}, {0,0,1,1,1,1..

다음과 같은 공백 입력일때 어떻게 입력을 받아야 하는지 몰라서 한참을 헤맸다.. 5엔터,3엔터,2엔터,3엔터,,,이런식으로 들어오는줄 알고 코드를짰다. BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int N = Integer.parseInt(bf.readLine()); 그런데 실제로 입력은 5 3 한줄 2 3 1 2 1 한줄 이렇게 입력이 들어오니 bf.readLine이 String을 호출하면서 파싱에러가 생길수밖에없었다. StringTokenizer를 이용하자. BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); StringTok..
자바 풀이 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); //공의갯수 int N = sc.nextInt(); //팀의수 int K = sc.nextInt(); int[] arr = new int[K]; int ballCnt = 0; for(int i = 0; i < K; i++) { arr[i] = i+1; ballCnt += i+1; } //최소로주고 남은 공의 수 int addBall = N-ballCnt; //공이 부족할경우 if(N < ballCnt) { System.out.println(-1); return; //최소로만 ..

* 빌드하기가 어렵네요 ㅠ 아시는분 댓글로 부탁드려여,, 1. james-project의 pom.xml를 확인합니다. 각각 dependency 리스트를 관리합니다. io.projectreactor reactor-bom Californium-SR3 pom import ${james.groupId} apache-james-backends-cassandra ${project.version} ${james.groupId} apache-james-backends-cassandra ${project.version} test-jar ${james.groupId} apache-james-backends-es ${project.version} 2. 추가할 모듈 dependency를 추가하겠습니다. ${james.grou..

이클립스를 이용해서 Apache James 소스를 빌드해서 실행해보겠습니다. 1. Git에서 소스를 내려습니다. Clone할 주소 : github.com/apache/james-project.git 2. repository 우클릭 -> Import Project -> Show other specialized import wizards -> Existing Maven Projects 반드시 show other..클릭해서 Existing Maven Projects로 임포트 해주도록 합니다. 3. james-server/james-server-app/src/man/resource에 james-database.properties설정파일을 수정합니다. database.driverClassName=oracle.jd..
파일첨부 중 insertBoard 시에 selectkey를 사용해 boardNo값을 가져왔으나 log에 5번찍힘 -> db에 6번글로등록 log에 6번찍힘 -> db에 7번글로등록 selectkey에 문제가있어보임 select seq_board.nextval from dual insert into tbl_board(bno, title, content, writer) values(seq_board.nextval, #{title},#{content} ,#{writer}) insert부분의 시퀀스에서 nextval이 한번더 됐기때문에 값이 1증가돼서 db에 insert됨... values(#{bno}, #{title},#{content} ,#{writer}) keyProperty로 선언한값으로 변경해서 해결!