====== Java ====== ===== Basic ===== * 기본 연산, 제어 구조 * 산술 연산, 논리 연산 * 자료형; 기본자료형, 참조형, 인스턴스, 래퍼클래스, 상수 * 비교 연산; 주요 비교 연산자, 참조형 비교, String 비교, 자료형 비교(instanceof 연산자), 논리 연산 * 조건 분기; if, switch, for, while, do-while, break, continue, return * 객체지향 * 캡슐화 * 상속 * 생성자 * 다형성 * 인터페이스 * 위임 * 제네릭 * 람다식 ===== Preparing ===== * 개발환경 구성 * JDK * IDE 혹은 TextEditor * Build 도구 (Maven, Gradle) 및 의존성관리 * 기타 개발 도구 ===== Examples ===== * ''String'' -> ''StringBuilder'' * ''java.util.Date'' <-> ''java.time.Instant'' * ''java.util.Calendar'' -> ''java.time.Instant'' * ''java.text.SimpleDateFormat'' * ''java.time'' * Local * Zoned * Offset * Collections * List; ArrayList, LinkedList * Set; HashSet, LinkedHashSet * Map; HashMap, LinkedHashMap * * 람다식 (자료형 인수, ...) -> { ... 임의의 처리 ...} ==== Database ==== import java.sql.*; ... ... Connection conn = null; try { Class.forName("DRIVER"); } catch(ClassNotFoundException e) { e.printStackTrace(); } try { conn = DriverManager.getConnection("jdbc database", "user", "password"); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("QUERY"); while(rset.next()) { // do something } } catch(SQLException e) { e.printStackTrace(); } finally { if(conn != null) { try { conn.close(); conn = null; } catch(SQLException e) { e.printStackTrace(); } } } ... ... * conn.setAutoCommit(true/false); * conn.commit(); * conn.rollback() * PreparedStatement stmt = conn.prepareStatement(".... ?"); * stmt.setString(1, "value"); * DAOData Access Object * DTOData Transfer Object * JPAJava Persistence API ==== File I/O ==== * FileReader * BufferedReader * Scanner * Files * CSV, XML, LOGGER ==== Tests ==== * JUint * @Test * @Before * @After * @BeforeClass * @AfterClass * @Ignore * import static org.junit.Assert.*; * assertEquals() * fail() * assertThat() * import static org.hamcrest.CoreMatchers.*; * is() * JMockit * DbUnit ==== Reserved Words ==== * data types * byte * short * int * long * float * double * char * boolean * void * class & packages * class * interface * enum * package * import * extends * implements * this * super * new * modifiers * public * protected * private * static * final * abstract * native * volatile * transient * synchronized * strictfp * operations * if * else * switch * case * default * for * while * do * break * continue * return * instanceof * assert * exceptions * try * catch * finally * throw * throws * others * const * goto ===== References ===== * [[https://wikidocs.net/book/31|점프 투 자바]] * [[https://m.blog.naver.com/ehe123/221290351142|[자바 IDE] IntelliJ vs Eclipse 비교]] * [[https://madplay.github.io/post/difference-between-dollar-sign-and-sharp-sign-in-mybatis|MyBatis에서 샾(#{})과 달러(${})의 차이는 무엇일까?]] * [[https://java-design-patterns.com/principles/|Java Design Patterns]] * [[https://github.com/iluwatar/java-design-patterns|Design patterns implemented in Java]] * [[https://github.com/lesstif/TIL/blob/master/JAVA/%EC%9E%90%EB%B0%94-%EC%BD%94%EB%93%9C%EB%A5%BC-%EC%A1%B0%EC%9E%91%ED%95%98%EB%8A%94-%EB%8B%A4%EC%96%91%ED%95%9C%EB%B0%A9%EB%B2%95.md|자바-코드를-조작하는-다양한방법.md]]