전체 글
-
[Java] 자바 문자열 비교프로그래밍 언어/Java 2022. 2. 10. 10:49
자바의 String의 특성을 고려하여 문자열을 비교한다. String을 비교할 때는 '=='과 equals() 메소드를 사용한다. 예시코드 1 public class stringtest { public static void main(String[] args) { String s1 = "홍길동"; String s2 = "홍길동"; if(s1 == s2) { System.out.println("이름이 같다."); } else { System.out.println("이름이 다르다."); } String s3 = new String("홍길동"); if(s2 == s3) { System.out.println("이름이 같다."); } else { System.out.println("이름이 다르다."); } } } ..
-
[Java] 익명클래스프로그래밍 언어/Java 2022. 2. 10. 10:41
익명클래스는 메인 메소드 내에서 메소드를 오버라이드 할 수 있다. class Student { public void gotoSchool() { System.out.println("학교에 간다."); } } public class interface02 { public static void main(String[] args) { Student stu = new Student() { public void gotoSchool() { System.out.println("오늘은 늦게 학교에 간다."); } }; stu.gotoSchool(); } }
-
[Java] 자바 인터페이스 사용프로그래밍 언어/Java 2022. 2. 10. 10:30
자바에서 인터페이스(interface)는 하위 클래스에서 메소드 구현을 강제하도록 한다. 하위 클래스가 가지는 기능(Methos)을 정의하고 있다. 단순한 덧셈, 뺄셈 메소드를 인터페이스로 구현한다. 인터페이스 선언 interface Calculator { int calculate(int a, int b); } 하위 클래스 구현 implements 키워드로 인터페이스를 상속받아서 구현한다. class Plus implements Calculator { public int calculate(int a, int b) { return a + b; } } class Minus implements Calculator { public int calculate(int a, int b) { return a - b; }..
-
[코딩테스트, C++] 코딩테스트를 위한 C++ 기본 템플릿코딩테스트 2021. 12. 20. 02:01
상 / 하 / 좌 / 우 / 대각 dx, dy 정의 int dx[4] = { -1, 0, 1, 0 }; // 좌우상하 int dy[4] = { 0, 1, 0, -1 }; int dx[8] = {-1, 1, 0, 0, -1, 1, 1, -1}; // 좌우상하 int dy[8] = { 0, 0, 1, -1, 1, 1, -1, -1}; N x N 크기의 2차원 벡터 입력 받기 int n; vector board; vector tv; ... ... cin >> n; for (int i = 0; i > temp; tv.push_back(temp); } board.push_back(tv); tv.clear(); }..
-
[코딩테스트 , Python] 파이썬 코딩테스트 문법 정리코딩테스트 2021. 12. 20. 02:00
문자열과 내장함수 msg = "String" msg = msg.upper() # 대문자 msg = msg.lower() # 소문자 x.isupper() x.islower() index = msg.find('T') # 문자 찾기 cnt = msg.count('T') # 개수 msg = msg[:2] # 슬라이스 ord(x) # 아스키코드 s.replace(",", "") # 특정 문자 제거 s.split(' ') s.split(',') # 특정 문자 기준으로 분리 리스트와 내장함수 a = [] a = list() if not a: # 비었을 때 if a: a = list(range(1, 11)) # 리스트 숫자로 초기화 a.append(6) # 숫자 6넣기 a.insert(3, 7) # 3인덱스에 7추가 ..
-
[코딩테스트, Java] 자바 코딩테스트 문법 정리코딩테스트 2021. 12. 20. 01:56
import java.util.*; import java.io.*; ArrayList 깊은복사 ArrayList w=new ArrayList(); ArrayList copy_w=new ArrayList(); copy_w.addAll(w); Sort, Size ArrayList ArrList=new ArrayList(); ArrList.sort(null); ArrList.size(); List set을 List로 변경하기 ⇒ List의 생성자에 set을 넣어준다. Set set = new HashSet(); List aList = new ArrayList(set); Sort ⇒ List를 정렬할 때 Collections의 sort() 메소드를 이용한다. Collections.sort() add() remo..
-
[Spring Boot] 프로젝트 생성하기웹프로그래밍 2021. 12. 20. 01:52
스프링 부트 프로젝트 생성 인텔리제이나 이클립스 IDE 환경에서 직접 프로젝트를 생성해도 되지만 스프링 부트 프레임워크 구조대로 프로젝트를 쉽게 생성할 수 있는 사이트가 있다. 아래 사이트를 이용하면 Dependencies 설정과 동시에 스프링 부트 프로젝트를 생성할 수 있다. 링크 : https://start.spring.io/ Project Metadata Group : 패키지 이름 Artifact. Name : - Dependencies Thymeleaf : 프론트단 템플릿 엔진 Spring Data JPA : JPA를 쉽게 구현할 수 있는 모듈 MySQL Driver : 사용할 데이터베이스 모듈 H2 Database : 테스트용으로 사용할 데이터베이스로 매우 가벼움 설정완료 후 [GENERATE]..