Methods of Java · Introduction to Java Programming

Different Types of Packages

Watch lectures

Different Types of Packages

1. Two Families (beginner)

Built-in (JDK gives: java.lang, java.util, java.io...) vs User-defined (YOU make: com.college.fees!). Both imported same way!

2. Built-in Tour (exam list!)

Package Gives Needs import?
java.lang String, System, Math, wrappers NO (auto!)
java.util Scanner, ArrayList, HashMap, Random YES
java.io File, streams YES
java.sql JDBC (Module 6!) YES
java.awt / javax.swing GUI (Module 5!) YES
java.time LocalDate, LocalTime YES

3. User-Defined (organize YOUR code!)

// fees/Student.java
package com.college.fees; // YOUR namespace!
public class Student { /* ... */ }
// use:
import com.college.fees.Student; // same import style!

Sub-packages: com.college.fees ≠ com.college (no auto-see! import each!).

4. CLASSPATH (where Java looks!)

Order: current dir → CLASSPATH env → -cp flag. java -cp .:lib/* Main (jars included!). Wrong path → NoClassDefFoundError!

5. Exam Points

  • Built-in table + user example — 5 marks, frequent.
  • Auto-import (lang) vs needed + CLASSPATH — 3 marks, frequent.
Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.

← All Introduction to Java Programming modules