initialization

Slurp an INI file in CFML

Could anyone find a way of improving this code a bit? I want to read in an INI file in one felt swoop and create a corresponding data structure. <cfset INIfile = expandPath(".") & "\jobs.ini"> <cfset profile = GetProfileSections(INIfile)> <cfloop collection="#profile#" item="section"> <cfloop list="#profile[section]#" index="entry"> ...

static variable initialization java

how to initialize a private static member of a class in java. trying the following: public class A { private static B b = null; public A() { if (b == null) b = new B(); } void f1() { b.func(); } } but on creating a second object of the class A and then calling f1(), i get a null pointer except...

Multiple initialization in C# for cycle

How can I (if it is possible at all) intialize multiple variables of different type in C# for cycle? Example: for (MyClass i = 0, int j = 1;j<3;j++,i++) ...

How can I initialize a String array with length 0 in Java?

The Java Docs for the method String[] java.io.File.list(FilenameFilter filter) includes this in the returns description: The array will be empty if the directory is empty or if no names were accepted by the filter. How do I do a similar thing and initialize a String array (or any other array for that matter) to have a length 0? ...

Adding elements to an STL Map in a constructors Initialization List?

I was wondering if this was possible, and if so how I'd go about doing so. If it's not possible I'll just have to add the elements during the constructor body. Ideally I would like the map immutable after construction. What I'm trying to achieve is adding two pairs to the map that are created from constructor parameters. ...

Visual studio 2005: is there a compiler option to initialize all stack-based variables to zero?

This question HAS had to be asked before, so it kills me to ask it again, but I can't find it for all of my google and searching stackoverflow. I'm porting a bunch of linux code to windows, and a good chunk of it makes the assumption that everything is automatically initialized to zero or null. int whatever; char* something; ...and...

How to specify WPF Theme in c#?

Hi ! I found out that I can use a different theme in an C# WPF Application by adding the theme .xaml-file to the project and add to App.xaml as a Resource. see http://wpf.codeplex.com/wikipage?title=WPF%20Themes for a more detailed description. Can I do this as well at runtime in C#? Is it possible to specify a different theme for d...

hibernate post initialization

I would like to initialize class members of a persisted object as soon as Hibernate loads the object from the database. How can I do this ? More specifically: In the following persisted object, I would like to initialize date's timezone class Schedule { Calendar date TimeZone tz; } I cant do this in the constructor becaus...

How to initialize a shared library on Linux

Hi there, I am developing a shared library using c++ under Linux. I would like to user log4cxx for logging purposes. However, I'm not sure how to initialize this. For log4cxx I need to create a logger object. How can I make sure this object is created when my library is loaded? I suspect that it will be easiest to create the logger obj...

Initialize in Ruby

I used to have this public constructor_name() { this(param) } public constructor_name(int param) { this.param = param } in Java and what about ruby do we have this kind of self reference constructor ? ...

How do I get Google Closure to call my init function when DOM tree finished

I am looking for something like the $(document).ready function in jQuery, as I work on experimenting with using Closure. So, my question is simple, is there a function I am missing that will allow me to wait until my function is called when the DOM tree is done? I use unobtrusive javascript, so the idea of putting any javascript in my ...

Initializing array of objects with data from text file

I’m getting system error when I try to compile the code below on Visual C++ 2008 Express. What I’m trying to do is to initialize array of objects with data read from file. I think there is something wrong inside the while loop, because when I initialize these objects manually without the while loop it seems to work. Here is the code an...

Spring web Dependency Injection(IOC) and the ServletContextListener

Hi all, I have code which is structured as Spring beans and dependencies among them. This is only a small part of the code since the rest is 'legacy' code. At this point in time I would like to perform an action on one of these beans in an existing 'legacy' class that extends javax.servlet.ServletContextListener. This class initializes...

Multiple initializers in a Go if statement

Just discovered Go, and am very curious so far. I know I'm just being lazy, but I want to know if it is possible to initialize multiple variables in an if statement. I know that the following is possible: if x := 5; x == 5 { fmt.Printf("Whee!\n") } I've tried the following: if x := 5, y := 38; x == 5 { fmt.Printf("Whee! %d\n"...

Is Shared ReadOnly lazyloaded?

Hello! I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? How about ReadOnly itself without the shared? Example: System.Type.Delimiter ...

Suggest the best way of initialization of array ( or other objects ) .......

Hi, I am a bit confused in the following two ways of initialisations..... Way 1: - (void) myMethod{ NSArray *myArray = [[NSArray alloc] initWithObjects:obj1,obj1,nil]; [self setClassArray:myArray]; [myArray release]; } Way 2: - (void) myMethod{ NSArray *myArray = [NSArray arrayWithObjects:obj1,obj2,nil]; [self setClas...

In C#, is there a way to write custom object initializers for new data-types?

In C#, there's the "standard" initializer technique { Property1 = "a", Property2 = "b" }, and there are a couple of special variants for collections (list and dictionary). {value1, value2}, and { {"key1", value1 }, {"key2", value2} }. I'd like to have a recursive object initializer for a tree data type, but I don't know if there's any ...

In what order are the different parts of a class initialized when a class is loaded in the JVM?

Imagine a Java class which has most features that you can find in a class. For example: it inherits from another class, implements a couple of interfaces, includes some 'static final' constants, some final constants, some static variables, instance variables, a static block, an unnamed code block (just code in {}), constructors, methods...

When is it ok to change object state (for instance initialization) on property getter access?

(except for proxy setup!) I spent some time writing a question here regarding a better pattern for a problem I had - of a class that performed some conditional initialization on almost every property getter, since the initialization in the base class relied on data from the inheriting classes that wasn't available on construction. Whil...

Nested struct variable initialization

How can I initialize this nested struct in C? typedef struct _s0 { int size; double * elems; }StructInner ; typedef struct _s1 { StructInner a, b, c, d, e; long f; char[16] s; }StructOuter; StructOuter myvar = {/* what ? */ }; ...