Arrays of strings

You can define String array as you define the int array. For example:

public class Main {
  public static void main(String args[]) {
    String str[] = {"one", "two", "three","java2s.com"};

    for (int i = 0; i < str.length; i++)
      System.out.println("str[" + i + "]: " + str[i]);
  }
}  

Here is the output from this program:


str[0]: one
str[1]: two
str[2]: three
str[3]: java2s.com
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.