java import method from another class code example

Example 1: how to import class from another file in java

import package.myclass;

//But since it's the default package and same, you just create a new instance like:

elf ob = new elf();

Example 2: import classes from another project java

Right Click > Project.
Click Project Properties.
Click Java Build Path.
Click the Projects Tab.
Click the Add Button.
Select the Project.
Click OK.

Example 3: how to call a static method from another class in java

// Called from outside the MyUtils class.
double avgAtt = MyUtils.mean(attendance);

Tags:

Java Example