Importing packages in Java

前端 未结 7 836
一向
一向 2020-12-08 14:54

How to import a method from a package into another program? I don\'t know how to import... I write a lil\' code:

package Dan;
public class Vik
{
    public          


        
7条回答
  •  被撕碎了的回忆
    2020-12-08 15:10

    You don't import methods in Java, only types:

    import Dan.Vik;
    class Kab
    {
        public static void main(String args[])
        {
            Vik Sam = new Vik();
            Sam.disp();
        }
    }
    

    The exception is so-called "static imports", which let you import class (static) methods from other types.

提交回复
热议问题