当前位置: 代码迷 >> J2SE >> No enclosing instance of type .解决思路
  详细解决方案

No enclosing instance of type .解决思路

热度:105   发布时间:2016-04-24 14:48:00.0
No enclosing instance of type ...
小弟新学java,请教这段代码哪里出问题了,谢谢啊

public   class   College   {

public   class   Student{
String   sname=null;
String   sid=null;
  Student(){}
 
void   Setname(String   name){
this.sname=name;
}
void   nprint(){
System.out.println( "sname "+   sname);

}
}
           
    public   class   Mstudent   extends   Student{
      String   mname=null;
      void   setmname(String   name){
        this.mname=name;
     
      }
    void     mprint(){
    System.out.println( "Mname "+mname);
 
    }
    }
      public   class   Ustudent     extends   Student{
        String   fname=null;
        void   setfname   (String   name){
        this.fname=name;
        }
        void   fprint(){
          System.out.println( "Fname "+   fname);
        }
      }
     

    public   static   void   main(String[]   args   ){
 
        College   s=new   College();
      Student   s1=   new   Student();
      s1.Setname( "zhou ");
      s1.nprint();
   
    }
}



------解决方案--------------------
public class College { 

public static class Student{ 
String sname=null; 
String sid=null; 
Student(){} 
  
void Setname(String name){ 
this.sname=name; 

void nprint(){ 
System.out.println( "sname "+ sname); 




public class Mstudent extends Student{ 
String mname=null; 
void setmname(String name){ 
this.mname=name; 


void mprint(){ 
System.out.println( "Mname "+mname); 
  


public class Ustudent extends Student{ 
String fname=null; 
void setfname (String name){ 
this.fname=name; 

void fprint(){ 
System.out.println( "Fname "+ fname); 




public static void main(String[] args ){ 
  
College s=new College(); 
Student s1= new College.Student(); 
s1.Setname( "zhou "); 
s1.nprint(); 




红色是我加上的,这样应该可以了,呵呵
  相关解决方案