+ Start a Discussion
Praveen Kumar JhaPraveen Kumar Jha 

Declare and populate array of string containing month names

Declare and populate array of string containing month names viz. January, February
Best Answer chosen by Praveen Kumar Jha
sunny522sunny522
Hi Praveen,
     Go through the example below

Apex class:

public class DisplayArrayList{
public list<string> Arraylist{get;set;}
public DisplayArrayList(){
Arraylist=new list<string>();
Arraylist.add('January');
Arraylist.add('February');
Arraylist.add('March');
Arraylist.add('April');
Arraylist.add('May');
Arraylist.add('June');
Arraylist.add('July');
Arraylist.add('August');
Arraylist.add('September');
Arraylist.add('October');
Arraylist.add('November');
Arraylist.add('December');

}

}

Visualforce Page:

<apex:page controller="DisplayArrayList">
{!Arraylist}
</apex:page>

if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.


All Answers

Vamsi KrishnaVamsi Krishna
Praven,
are you looking for something like this ??

List<String> months = new List<String>{'January','February','March','April','May','June','July','August','September','October','November','December'};
sunny522sunny522
Hi Praveen,
     Go through the example below

Apex class:

public class DisplayArrayList{
public list<string> Arraylist{get;set;}
public DisplayArrayList(){
Arraylist=new list<string>();
Arraylist.add('January');
Arraylist.add('February');
Arraylist.add('March');
Arraylist.add('April');
Arraylist.add('May');
Arraylist.add('June');
Arraylist.add('July');
Arraylist.add('August');
Arraylist.add('September');
Arraylist.add('October');
Arraylist.add('November');
Arraylist.add('December');

}

}

Visualforce Page:

<apex:page controller="DisplayArrayList">
{!Arraylist}
</apex:page>

if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.


This was selected as the best answer
Praveen Kumar JhaPraveen Kumar Jha
@Vamsi Krishna:- i m getting error like :-
Error: DisplayArrayList Compile Error: The method String getArraylist() is referenced by Visualforce Page (MonthsDisplay) in salesforce.com. Remove the usage and try again
Anoop yadavAnoop yadav
Hi,

First you should save your "MonthsDisplay" Visualforce page by removing getArraylist() method (may be Like : Arraylist) from your page..
After that save your controler.

Praveen Kumar JhaPraveen Kumar Jha
Sunny  Create a method to return a string in below format :
January > February > …