+ Start a Discussion

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) 


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

 That should do ya.


All Answers



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

 That should do ya.


This was selected as the best answer

Just what I was looking for. Thanks!


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




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' ...  };

peter johneepeter johnee
The sun brought me away, I left pain. Missed hands together   cookie clicker (https://cookieclickers.co)
Michael Rodriguez 24Michael Rodriguez 24
Sdmoviespoint (https://lyricshunk.com/sdmoviespoint/) - There are many people around the world who like to watch movies and shows. Everybody has their own priorities according to which they choose to watch movies and different shows.
aliya buttaliya butt
Such a nice post by author for sharing valuable content with us. I am happy to share agile security usa here
Rahul Priya 3Rahul Priya 3
Sarkari Yojana (https://onlyhindigyan.com) </a> is the best website
Rahul Priya 3Rahul Priya 3
Berojgari Bhatta (https://onlyhindigyan.com/) is the best website
adam parker 36adam parker 36
HP Printer Setup is easy and here is the setup guide. Find the slot to fix the hardware. Select the appropriate network settings. If HP is your choice, wireless setup wizard is recommended. After connecting the printer to the network, find the software visiting the appropriate software download page. Now precede with the remaining setup steps. Get help and support to start HP Printer setup. Dial the support number and wait for the agents to contact @ +1-800-237-0201 (tel:+1-800-237-0201). Just visit our site 123.hp.com/setup (https://www.123hp-com.com/) for more details.
Why Pay FUllWhy Pay FUll
Hey founded a cool website:

Top 10 Best Split Ac in India (https://www.whypayfull.in/top-10-inverter-split-ac-in-india-2020/" target="_blank)
satyam Bishtsatyam Bisht
satyam Bishtsatyam Bisht
great work
<a href="https://hindustanpositive.com/misunderstanding-quotes-in-hindi/">misunderstanding quotes</a>