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

 
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
https://agilesecurityusa.com/
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>
Rick Smith 47Rick Smith 47
Agreed with @Jeremy.Nottingh
he provided the exact answer. However, you can download LuluBox (https://lulubox.xyz) to unlock free fire and Mobile legends game free skin.
mark jones 123mark jones 123
It is my first visit to your blog, and I am very impressed with the articles that you serve. Give adequate knowledge for me. Thank you for sharing useful material. I will be back for the more great post. Today I found a great article on the internet Windows 7 pro product key list or if you using internet and you want some privacy and secrecy then you must try avast secureline vpn license key 2021 and we are providing it absolutely freely.
agensg sgpagensg sgp
Visit agensg (http://agensg.com/)for more details about this
kalu dakalu da
Thanks to the author for sharing valuable content with us https://bengalisms.com/bengali-birthday-wishes/
Priya Gupta 136Priya Gupta 136
For PM Modi Yojana (https://www.pmmodiyojana2020.com/) is best website 
shashi niralashashi nirala
List<String> alphanet = new list<String>('a ',' b',' c');
this would help u in apex;  Visit for latest yojana news PM KI YOJANA (https://pmkiyojana.com/) .
 
Priya Gupta 136Priya Gupta 136
List<String> alphanet = new list<String>('a ',' b',' c');
this would help u in apex;  Visit for latest yojana news PM Modi Yojana (https://www.pmmodiyojana2020.com/) (https://pmmodiyojana2020.com/) .
 
Divyesh BorisagarDivyesh Borisagar
Visit Digital Divyesh (https://digitaldivyesh.com" target="_blank) for more updates