Mega Code Archive

 
Categories / Java Book / 003 Essential Classes
 

0179 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","rntsoft.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]: rntsoft.com