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 可能还没有被初始化!
                
}
}

解决方案 »

  1.   

    当用类似aaa cls_aaa语句时,仅产生一个对象的引用。对象本身本没有生成或还没有产生指向对象地址的指针。 
          aaa cls_aaa :  生成对象变量(实际是用来应用对象,并没有对象的数据结构)
          new aaa():  系统生成类aaa的实例,由于没有引用,用户看不到,但其已在内存中进行 
                      了分配,对象已存在。
          aaa cls_aaa=new aaa():生成类的对象,并生成一个引用;用户可以通过这个引用来调用
                      对象的数据和方法。
      

  2.   

    I put my comments inside your code. Hope you can understand English.// Error: You can't define your class as java.lang package.
    // 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!");
        }
    }