Top "Initialization" questions

Initialization deals with the task of initializing the contents of your data structure.

Initialization of an ArrayList in one line

I wanted to create a list of options for testing purposes. At first, I did this: ArrayList<String> …

java collections arraylist initialization
How to initialize all members of an array to the same value?

I have a large array in C (not C++ if that makes a difference). I want to initialize all members …

c arrays initialization array-initialize
JavaScript check if variable exists (is defined/initialized)

Which method of checking if a variable has been initialized is better/correct? (Assuming the variable could hold anything (string, …

javascript variables initialization undefined
How to initialize an array in Java?

I am initializing an array like this: public class Array { int data[] = new int[10]; /** Creates a new instance of Array */ …

java arrays initialization
How to directly initialize a HashMap (in a literal way)?

Is there some way of initializing a Java HashMap like this?: Map<String,String> test = new HashMap<…

java dictionary collections initialization
How can I initialise a static Map?

How would you initialise a static Map in Java? Method one: static initialiser Method two: instance initialiser (anonymous subclass) or …

java dictionary collections initialization idiomatic
What is the easiest way to initialize a std::vector with hardcoded elements?

I can create an array and initialize it like this: int a[] = {10, 20, 30}; How do I create a std::vector and …

c++ vector stl initialization
How to initialize HashSet values by construction?

I need to create a Set with initial values. Set<String> h = new HashSet<String>(); h.…

java collections constructor initialization hashset
How to initialize a struct in accordance with C programming language standards

I want to initialize a struct element, split in declaration and initialization. This is what I have: typedef struct MY_…

c struct initialization
Java: how to initialize String[]?

Error % javac StringTest.java StringTest.java:4: variable errorSoon might not have been initialized errorSoon[0] = "Error, why?"; Code public class StringTest { …

java string initialization