package java.lang;
class aaa
{
public void aa1(int a)
{
System.out.println("Hello World!");
}
};public class temp
{
public static void main(String[] args)
{
aaa cls_aaa = new aaa();
cls_aaa.aa1(1);///他总是说"变量cls_aaa 可能还没有被初始化!
}
}
class aaa
{
public void aa1(int a)
{
System.out.println("Hello World!");
}
};public class temp
{
public static void main(String[] args)
{
aaa cls_aaa = new aaa();
cls_aaa.aa1(1);///他总是说"变量cls_aaa 可能还没有被初始化!
}
}
aaa cls_aaa : 生成对象变量(实际是用来应用对象,并没有对象的数据结构)
new aaa(): 系统生成类aaa的实例,由于没有引用,用户看不到,但其已在内存中进行
了分配,对象已存在。
aaa cls_aaa=new aaa():生成类的对象,并生成一个引用;用户可以通过这个引用来调用
对象的数据和方法。
// This package name is reserved by Sun
package java.lang;
class aaa
{
// Warning: I don't understand why you need parameter 'a' here?
// It is not used inside the method
public void aa1(int a)
{
System.out.println("Hello World!");
}
};public class temp
{
public static void main(String[] args)
{
aaa cls_aaa;
// before you use any ojbect reference, you have to initialize it
// add the following line:
// cls_aaa = new aaa();
cls_aaa.aa1(1);///他总是说"变量cls_aaa 可能还没有被初始化!
}
}// I would like to give your a example about HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}