Java examples for Language Basics:Array
Here's a static method that creates and returns a String array with the names of the days of the week:
public class Main { public static void main(String[] args) { String[] days = getDaysOfWeek(); printStringArray(days);//from ww w . j ava2s .c o m } public static String[] getDaysOfWeek() { String[] days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; return days; } public static void printStringArray(String[] strings) { for (String s : strings) System.out.println(s); } }