如何静态生成类对象?
student类
student student1;这样??
那 怎么初始化呢??

解决方案 »

  1.   

    static  student student1= new student();
      

  2.   

    E:\java\实验\Data\student.java:25: illegal start of expression出错的
      

  3.   

    package LastMonth;
     class Student{
     Student(){
    System.out.println("Student  object  ");
    }
    }
    public class Sclass { /**
     * @param args
     */
    static Student  s ;
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    s =  new Student();
    }}
      

  4.   

    --------------------Configuration: j2sdk1.4.2 <Default>--------------------
    E:\java\实验\Data\student.java:25: illegal start of expression
        static student student3=new student("000","yy",9,data2);
                ^
    1 error这样 
      

  5.   

    不懂,你是不是想用静态方法产生对象!!
    public static Example getSimpton()
    {
       return new Example();
    }
      

  6.   

    static不能用于声明方法内的局部变量,你应该把static Student  s 放在类成员的声明中。
      

  7.   

    package LastMonth;
     class Student{
     Student(String name){
    System.out.println("Student  name is:  "+ name);
    }
    }
    public class Sclass { /**
     * @param args
     */
    static Student  s = new Student("louzhu");;
    public static void main(String[] args) {
    // TODO Auto-generated method stub
     
    }}