0

How do you use packages in java?

Hi! I use Sublime Text and I wanted to know how you insert java packages, do you just write package and the file extension?

1st Sep 2019, 10:39 PM
Sebastián Garavano Kleiner
Sebastián Garavano Kleiner - avatar
3 ответов
+ 1
if you have class LibClass and want add it to package Lib and then call it from Main code - LibClass must be public - LibClass must be in file LibClass.java - first statement in LibClass.java must be: package Lib; - in directory where you run Main code create subdirectory Lib - move LibClass.java into subdirectory Lib - in your Main code must be at beginning of file import Lib.LibClass; //or import Lib.*;
1st Sep 2019, 11:17 PM
zemiak
+ 1
yes, folder.
3rd Sep 2019, 5:48 AM
zemiak
0
Thank you so much. One question: what do you mean by subdirectory? Is it a folder?
2nd Sep 2019, 11:45 PM
Sebastián Garavano Kleiner
Sebastián Garavano Kleiner - avatar