본문 바로가기

Java

(501)
[JAVA] 프로그래머스 - 문자열을 정수로 바꾸기 https://school.programmers.co.kr/learn/courses/30/lessons/12925 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr    정답  class Solution { public int solution(String s) { int answer = 0; answer = Integer.parseInt(s); return answer; }}  다른 사람의 풀이  public class StrToInt { public int getStrToInt(String s..
[JAVA] 프로그래머스 - 문자열 내 p와 y의 개수 https://school.programmers.co.kr/learn/courses/30/lessons/12916 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr     정답  class Solution { boolean solution(String s) { boolean answer = true; s = s.toLowerCase(); //소문자로 변경 int pcnt = 0; int ycnt = 0; for(int i=0; i   다른 사람의 풀이  class ..
[JAVA] SWEA 1206. [S/W 문제해결 기본] 1일차 - View https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AV134DPqAA8CFAYh&categoryId=AV134DPqAA8CFAYh&categoryType=CODE&problemTitle=&orderBy=RECOMMEND_COUNT&selectCodeLang=JAVA&select-1=3&pageSize=10&pageIndex=1 SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com     정답  import java.util.Scanner;class Solution{ public static void main..
[JAVA] 프로그래머스 - 다음에 올 숫자 https://school.programmers.co.kr/learn/courses/30/lessons/120924 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr     시도 1) class Solution { public int solution(int[] common) { int answer = 0; int len = common.length; int temp1 = common[2]-common[1]; int temp2 = common[1]-common[0]; ..
[JAVA] 프로그래머스 - 종이 자르기 https://school.programmers.co.kr/learn/courses/30/lessons/120922 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr     시도 1) class Solution { public int solution(int M, int N) { int answer = 0; //가로 int cnt1 = M-1; //세로 int cnt2 = (N-1)*2; answer = cnt1+cnt2; re..
[JAVA] 프로그래머스 - 문자열 밀기 https://school.programmers.co.kr/learn/courses/30/lessons/120921 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr      StringBuilder 초기화, 모든 문자열 삭제 Java - StringBuilder 초기화, 모든 문자열 삭제 (codechacha.com) Java - StringBuilder 초기화, 모든 문자열 삭제StringBuilder.setLength(0)는 StringBuilder에 저장된 문자열의 길이를 0으로 변경합니다. 즉 문자열을 empty로 만든다는 것은 이전에 저장한 문자열을 ..
[JAVA] 프로그래머스 - 연속된 수의 합 https://school.programmers.co.kr/learn/courses/30/lessons/120923 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr      정답  import java.util.*;class Solution { public int[] solution(int num, int total) { ArrayList list = new ArrayList(); for(int i = -1000; i   다른 사람의 풀이 class Solution { public int[] soluti..
[JAVA] 프로그래머스 - k의 개수 https://school.programmers.co.kr/learn/courses/30/lessons/120887 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr     int to Char 형변환 java int to char 형변환 (tistory.com) java int to char 형변환알고리즘 풀며 정리하는 형변환 문자열에서 문자의 비교시 int 를 스트링 또는 char로 변환할 경우가 있다. Java에서int를char로 변환하는 메소드는(char),Character.forDigit()및toString() 가 있다. 1. (char) 타shutco..