请写出创建空集合的语句
时间: 2024-10-25 15:05:05 浏览: 12
在不同的编程语言中,创建空集合的方式各不相同。以下是几种常见语言的示例:
1. **Java**:
- `ArrayList`: `ArrayList<String> list = new ArrayList<>();`
- `HashSet`: `HashSet<Integer> set = new HashSet<>();`
- `HashMap`: `HashMap<String, String> map = new HashMap<>();`
2. **Python (列表)**:
```python
empty_list = []
```
3. **Python (集合)**:
```python
empty_set = set()
```
4. **JavaScript (数组)**:
```javascript
let emptyArray = [];
```
5. **C# (List)**:
```csharp
List<int> myList = new List<int>();
```
6. **C# (Dictionary)**:
```csharp
Dictionary<string, int> myDict = new Dictionary<string, int>();
```
7. **C++ (std::vector)**:
```cpp
std::vector<int> vector;
```
8. **C++ (std::set)**:
```cpp
std::set<int> set;
```
阅读全文