Learn Java Tutorial for Beginners (Video), Part 24: Packages

How to use packages in Java. Packages are an important tool for organising your code; you'll also need to understand packages to use other people's code.

When the video is running, click the maximize button in the lower-right-hand corner to make it full screen.



Code for this tutorial:

App.java:

 

import ocean.Fish;
import ocean.plants.Seaweed;

public class App {

    
    public static void main(String[] args) {
        Fish fish = new Fish();
        Seaweed weed = new Seaweed();
    }

}

 

Fish.java:

 
package ocean;

public class Fish {

}
 

Algae.java:

 
package ocean.plants;

public class Algae {

}

 

Seaweed.java:

 
package ocean.plants;

public class Seaweed {

}
 

Aquarium.java:

 
package com.caveofprogramming.oceangame;

public class Aquarium {

}