Home >Common Problem >What are the methods of assigning values to string arrays?
The assignment methods of string arrays in common programming languages: 1. Python: "string_array = ["apple", "banana", "cherry"]"; 2. Java: "String[] stringArray = { "apple", "banana", "cherry"}"; 3. C and so on.
#In programming, the assignment method of string arrays will vary depending on the programming language. Here, I will give some ways to assign string arrays in common programming languages:
1, Python:
string_array = ["apple", "banana", "cherry"]
2, Java:
String[] stringArray = {"apple", "banana", "cherry"};
or in Java 9 In and above versions, you can also use:
Listf7e83be87db5cd2d9a8a0b8117b38cd4 list = Arrays.asList("apple", "banana", "cherry");
3. C :
#include <string> #include <vector> std::vector<std::string> stringArray = {"apple", "banana", "cherry"};
Or use C-style string array:
char* stringArray[] = {"apple", "banana", "cherry"};
4, JavaScript:
let stringArray = ["apple", "banana", "cherry"];
5, C#:
string[] stringArray = { "apple", "banana", "cherry" };
6, Ruby:
string_array = ["apple", "banana", "cherry"]
7. Go:
The string array in Go language is as follows:
var stringArray = []string{"apple", "banana", "cherry"}
The above is the detailed content of What are the methods of assigning values to string arrays?. For more information, please follow other related articles on the PHP Chinese website!