String array


1 ActionScript[ | ]

var weekDays:Array = new Array( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" );

2 C++[ | ]

#include <iostream>
using namespace std;
int main() {
    char fruits[3][10] = {"apple", "banana", "cranberry"};
    for(int i=0; i<3; i++) cout << fruits[i] << " ";
    // apple banana cranberry 
}
#include <iostream>
using namespace std;
int main() {
    string fruits[3] = {"apple", "banana", "cranberry"};
    for(int i=0; i<3; i++) cout << fruits[i] << " ";
    // apple banana cranberry 
}
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<string> fruits;
    fruits.push_back("apple");
    fruits.push_back("banana");
    fruits.push_back("cranberry");
    for(int i=0; i<fruits.size(); i++) cout << fruits[i] << " ";
    // apple banana cranberry 
}

3 C#[ | ]

string[] stringArray = new string[6];

string[] weekDays = new string[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };

string[] weekDays2 = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };

4 Java[ | ]

String[] weekDays = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
System.out.println(Arrays.toString(weekDays));
// [Sun, Mon, Tue, Wed, Thu, Fri, Sat]

5 Objective-C[ | ]

NSArray *weekDays = [NSArray arrayWithObjects:@"Sun", @"Mon", @"Tue", @"Wed", @"Thu", @"Fri", @"Sat", nil];

6 Perl[ | ]

@weekDays = ( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" );

$weekDays_ref = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ];

7 PHP[ | ]

$weekDays = array( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" );

8 Python[ | ]

weekDays = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]

9 Ruby[ | ]

fruits = ['apple', 'banana']
print fruits
# ["apple", "banana"]

10 See also[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}