<commit_before><commit_msg>upload 01 array and string<commit_after>---
title:"자료구조 : 01 배열과 문자열"
layout: post
---


# Array and String  


<br/>

## hash table  

```java
public HashMap<Integer, Student> buildMap(Student[] students) {
  HashMap<Integer, Student> map = new HashMap<Integer, Student>();
  for (Student s : students) map.put(s.getId(), s);
  return map;
}
```  


<br/>

## ArrayList  

```java
public ArrayList<String> merge(String[] words, String[] more) {
  ArrayList<String> sentence = new ArrayList<String>();
  for (string w : words) sentence.add(w);
  for (string w : more) sentence.add(w);
  return sentence;
}
```


<br/>

## StringBuffer

```java
public String joinWords(String[] words) {
  StringBuffer sentence = new StringBuffer();
  for (String w : words) {
    sentence.append(w);
  }
  return sentence.toString();
}
```
{'fraction_non_alphanumeric': 0.16372202591283863, 'fraction_numerical': 0.004711425206124852, 'mean_word_length': 4.089820359281437, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1365682', 'n_tokens_mistral': 294, 'n_tokens_neox': 292, 'n_words': 80}