일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- 보늬밤
- Kotlin
- LRU
- FirebaseAuth
- synergy
- stack
- math
- DataStructure
- 쌓기게임
- Dialog
- DynamicProgramming
- 리틀포레스트
- devicedriver
- 제곱근
- Collection
- SPI
- WebView
- 피요모리2
- Java
- 동적프로그래밍
- 피보나치
- android
- Dokka
- AfxMessageBox
- 형변환
- 코인거스름돈
- MFC
- darkmode
- QoS
- memory
- Today
- Total
목록Computer/Java (6)
퉁탕퉁탕 만들어보자

HashMap을 굉장히 자주 사용하는데 String 이나 POJO 같은 Object를 key로 사용할 수 있어서 편리하다. 저 Object를 가지고 내부적으로 key를 어떻게 사용하는지 알아보자 public V put(K key, V value) { return putVal(hash(key), key, value, false, true); } hash(key) 함수로 hash값을 만들어서 사용하는데, 그 리턴값의 타입이 int다. hash함수를 보면 key라는 Object의 int를 리턴하는 hashCode() 함수를 바로 사용을 하고 있다. key가 Object의 hashCode 로 int를 사용한다는 것은 2의 32승 개의 key를 가질수 있는 구조다. 또한 그러면 HashMap에서 get으로 원소를..
InputStream을 봤으니 OutputStream도 보자,, public static void writeToFile(Context context, String fileName, List data) { try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( context.openFileOutput(fileName, Context.MODE_PRIVATE))) { for (String str : data) { writer.write(str); writer.write("\n"); } } catch (IOException e) { Log.e(TAG, "IOException occurred during file write: " + e.to..
네트워크나, 파일 입출력을 하게될때 InputStream이나 OutputStream을 사용하게된다. 네크워크에서 String을 읽어오는 예제를 보자 HttpURLConnection connection = openConnection(src); if (!isValidResponse(connection)) { Log.e(TAG, "Connection error : " + connection.getResponseCode()); connection.disconnect(); return null; } try (InputStream inputStream = connection.getInputStream()) { List mImageSrcList = new LinkedList(); try (BufferedReader ..

java 의 타입은 크게 primitive type, reference type, null type 3가지가 있다. primitive type이란 boolean, int, char와 같은 타입이다. 이 타입은 이름공간에 바로 값이 저장되기 때문에 stack에 저장된다. (array제외) reference type은 class의 instance로 생성된 object들이 reference타입이다. 얘네들은 heap영역에 할당된다. reference type은 그 값을 참조하는 친구가 stack에 주소를 갖고있고, 실제 값은 heap에 할당된다. 따라서 == operator가 아닌 equals() 메소드로 비교를 해야한다. // reference type Person p = new Person(); // pr..
Math class들 중 유용한 API들을 정리해보았다 static double ceil(double a) 올림 static int round(float a) 반올림 static double floor(double a) 내림 static double pow(double a, double b) a의 b제곱 static double sqrt(double a) a의 제곱근 static int abs(int a) 절대값 static double random() 0.0

String 함수들 잘 쓰면 코드작성시간을 줄여준다. charAt(i) : 특정 문자열의 위치 toCharArray() => char[] substring(begin, end) 주의! end는 포함되지 않음 compareTo(String anotherString) : 사전순서대로 비교해준다. Character.isDigit(c), Character.isLetter(c): 숫자? 문자? 문제에 적합한 자료구조 선택하기 크게 List, Set, Map 세가지이다. 1. List 일반적인 데이터 모음에 사용 size가 정해지지 않은 동적배열이 필요할때 사용 그렇지 않은경우 Array 사용 ArrayList 중간 index 접근이 필요한경우. ArrayList는 내부적으로 배열을 유지하면서 관리된다. Array..