package در جاوا

  • package is same as a folder that contains the related .class file.
  • to create a package the keyword "package" is used.
  • the classes in the package should be declared as a public.
  • if you want to use this classes in another class outside the package then
    you have to import to that class using import keyword.
  • using import keyword you can import a single or particular class or all
    the classes using * operator.
  • the * operator imports only classes present in that package. not the sub packages.
  • to compile a class that contains a package we use "javac -d . programname.java"
  • "-d" describe to create the directory. "." describes the part of directories same where the file is stored.
  • the package statement should be the first statement in the program and only
    one package statement can be written inside a program whereas n number of
    import statement we can write.
  • if class is not public we can not use it outside the package.
نظرات 0 + ارسال نظر
برای نمایش آواتار خود در این وبلاگ در سایت Gravatar.com ثبت نام کنید. (راهنما)
ایمیل شما بعد از ثبت نمایش داده نخواهد شد