这在对象的构造函数中完成,和之前清单2中的例子一样。
This is done in the object's constructor, just as you've done in the previous example in Listing 2.
尽管调用了析构函数,但是未调用数组中各个对象的构造函数。
The constructors for the individual objects in the array are not invoked, although the destructors are.
然而,此对象的构造函数尚未运行,这恰是破坏双重检查锁定的情况。
However, the constructor for this object has not run yet, which is precisely the situation that breaks double-checked locking.
为了解决这一问题,可以在抛出异常语句期间,在异常对象的构造函数中生成一个堆栈跟踪。
To deal with this, you can generate a stack trace in the constructor of the exception object during the throw exception statement.
类的这种重构也会改进代码,因为我们将初始化逻辑从对象的构造函数分离出来了。
This refactoring of the class also improves the code so that we have separated the initialization code from the object construction code.
这个对象的构造函数从进来的XML文档收集信息,以便填充MIB中指定的 “名/值”对。
The constructor for this object pulls together information from the incoming XML document so that the name value pairs specified in the MIB can be populated.
线程1通过运行Singleton对象的构造函数并将引用返回给它,来完成对该对象的初始化。
Thread 1 completes the initialization of the Singleton object by running its constructor and returns a reference to it.
下一步是把业务对象实现指定给调用处理程序的构造函数。
The next step is to specify a business object implementation to the constructor of the invocation handler.
构造函数只是创建特定类实例(或对象)的特殊方法。
A constructor is just a special method that creates an instance (or object) of a particular class.
该组对象是用于构造函数调用的参数值。
The array of objects are the parameter values used for the constructor call.
更改过的构造函数只对更新后才创建的对象生效。
Changing constructors will only have effect on objects created after the update.
YUIProfiler可以注册要测量的函数、类构造函数和对象。
YUI Profiler allows you to register functions, class constructors, and objects to be measured.
首先,Prototype的Request对象为其构造函数获取两个参数。
For starters, Prototype's Request object takes two parameters to its constructor.
Joda支持使用许多其他对象作为构造函数的参数,用于创建DateTime,如清单5所示。
Joda supports a number of other objects as the constructor parameter for creating a DateTime, as shown in Listing 5.
self对象是由Box构造函数创建的,后者也覆盖返回值,如清单3 所示。
The self object is created by the Box constructor, which also overrides the return value, as seen in Listing 3.
在这两种情况下,您都需要声明依赖项(例如使用Spring配置文件),并向依赖对象类添加对应的构造函数或mutator方法。
In both cases you need to declare the dependency (e.g. using the Spring configuration file) and add a corresponding constructor or mutator method to the dependent object class.
它的构造函数创建共享内存及其中的对象。
Its constructor creates the Shared memory and objects in it.
如果您有一个不可变对象,则必须要在构造函数中设置该对象将包含的任何状态。
If you have an immutable object, you must set whatever state it will contain in the constructor.
如果想让对象的属性和字段都为只读并可在构造函数中进行设置,那么我们仍然需要像在。NET 1.0那样编写代码。
If you want objects where the properties and fields are all read-only and set in constructors, you still have to write the same code you would write in.net 1.0.
回想一下,构造函数以可选参数的方式接受缓存对象。
Recall that the constructor takes the cache object as an optional argument.
现在我们不依赖于外部的全局对象,只是通过构造函数传递对象实例。
Now we don't depend on external global objects, just on the instances passed in the constructor.
这些类定义了修改由它们所表示的对象的所有方法的方法,包括方法或者构造函数中的实际字节码内容。
These classes define methods for modifying all aspects of the item represented by the class, including the actual bytecode body of a method or constructor.
还可以使用此接口创建普通对象,而不调用它们的构造函数。
You can also create vanilla objects without calling their constructors using this interface.
初始化这些字段不需要逻辑上的构造函数,这和很多面向对象语言不同。
No constructor logic is required to initialize these fields, in contrast to most other object-oriented languages.
构造函数注入利用构造函数判断要返回的具体对象类型。
Constructor injection USES a constructor to determine what type of concrete object to return.
此事件序列发生在线程2返回一个尚未执行构造函数的对象的时候。
This sequence of events results in a period of time where thread 2 returned an object whose constructor had not executed.
一个不可变对象的状态在其构造完成之后就不可改变,换句话说,构造函数是唯一一个您可以改变对象的状态的地方。
An immutable object's state cannot change after construction. In other words, the constructor is the only way you can mutate the object's state.
只要有可能,应该避免创建对象,防止调用构造函数带来的相关性能成本,以及在对象结束其生命周期时进行垃圾收集所带来的成本。
Whenever possible, avoid creating objects to prevent associated performance costs of calling the constructor, and subsequent cost of GC when an object reaches the end of its lifecycle.
实现标准的面向对象功能,比如:私有构造函数、抽象方法和抽象类等。
Implement standard OOP features like private constructors, abstract methods and classes.
实现标准的面向对象功能,比如:私有构造函数、抽象方法和抽象类等。
Implement standard OOP features like private constructors, abstract methods and classes.
应用推荐