请问用如果要调用一个类的方法,像下面的为什么不行
比如
class Point{
    void output(){
}
}
class stuff{
    Point pt = new Point();
    pt.output();//这里为什么不可以?
}

解决方案 »

  1.   

    你是在不同的包中调用的吧,看这里http://blog.csdn.net/lovingprince/archive/2008/07/17/2664122.aspx
      

  2.   


    class Point{ 
        void output(){ 


    public class stuff{ 
       public static void main(String[] args){
        Point pt = new Point(); 
        pt.output();
    }

    这样就可以了
      

  3.   

    class stuff{ 
        Point pt = new Point(); 
        pt.output();//这里为什么不可以? 
    } 楼主仔细看看,这些语名可以出现在这里吗?只能在方法里面了,看看3楼
      

  4.   


    class Point1{ 
        void output(){
         System.out.println("fdsfsd"); 


    class Stuff{ 
    void abc(){
        Point1 pt = new Point1(); 
        pt.output();
      }
    } public class A{
    public static void main(String[] args){
    Stuff p = new Stuff();
    p.abc();
    }
    }
    你看看这个