基本 Java 初始化概念

Basic Java Initialize concept

本文关键字:初始化 Java 基本      更新时间:2023-09-26
Data (Global Variables):
Car color.
Car x location.
Car y location.
Car x speed.

设置:

Initialize car color.
Initialize car location to starting point.
Initialize car speed.

画:

Fill background.
Display car at location with color.
Increment car's location by speed.

我从一个基本概念初始化的网站上读到了这一点。

为什么我们需要初始化?

它对创建对象有什么帮助?

我们如何调整并为我们需要的对象进行正确的初始化?

如果不初始化,您将无法访问 objects 属性(因为它是未定义的(。

var test = {
    definedProperty : "Hello"
};
alert(test.definedProperty);
alert(test.undefinedProperty);

http://jsfiddle.net/3cWzw/