+ Start a Discussion
d3developerd3developer 

Initializing List of Strings with Json-like Format

Okay folks, I know this is a n00b question but I can't remember if or how to initialize a string with a set of arguments.

 

What I want to do is something like this

 

 

List<String> alphabet = { 'a' , 'b' , 'c' ...  };

 

How can I do this?

 

Best Answer chosen by Admin (Salesforce Developers) 
Jeremy.NottinghJeremy.Nottingh

 

List<String> alphabet = new list<String> { 'a' , 'b' , 'c' ...  };

 That should do ya.

 

All Answers

Jeremy.NottinghJeremy.Nottingh

 

List<String> alphabet = new list<String> { 'a' , 'b' , 'c' ...  };

 That should do ya.

 

This was selected as the best answer
d3developerd3developer

Just what I was looking for. Thanks!

 

While we are at it, anyone have the code for including initialization and getter / setter fucntions?

 

Like:

 

public List<String> alpha { 'a', 'b' ... } {get; set;}

 

 

Harsh vardhana 10Harsh vardhana 10

List<String> alphanet = new list<String>('a ',' b',' c');

this would help u in apex;

Mohammed MohiddinMohammed Mohiddin
Try this 
 
List<String> alphabet {get;set;}

public constructor(){
 alphabet = new list<String> { 'a' , 'b' , 'c' ...  };
}