Java Packages — தமிழ்

</>Coding Tamilan.← Java course & curriculum
Java Masterclass · Lesson 31 / 50 · தமிழ்

Java Packages

Organize types and make dependencies clear.

Step-by-step explanationsRunnable JavaPractice + answer

முக்கிய விளக்கங்கள் தமிழில் உள்ளன. Runnable example மற்றும் கூடுதல் practice notes ஆங்கிலத்தில் உள்ளன.

இந்தப் பாடத்தில்…

  • Explain the key idea behind Packages.
  • Read and run a complete example, then predict what changes.
  • Recognize the topic-specific mistake discussed below.
01 / The concept

அடிப்படையைப் புரிந்துகொள்ளுங்கள்

A package is a namespace for related Java types. An import lets you use a type name without spelling its fully qualified name each time; it does not install a library. Multi-file package layouts are easiest to practice locally. The single-file browser example below demonstrates importing a standard-library class.

02 / Step by step

விரிவான விளக்கங்கள்

Java Packages என்னன்னு தெரியுமா?

Package என்பது related classes-ஐ group பண்றதுக்குள்ள folder மாதிரி. Name conflicts avoid பண்றதுக்கும், code-ஐ maintain பண்றதுக்கும் help ஆகும்.

Java இரண்டு வகை packages வையுங்கள்க்கும்:

  • Built-in packages — Java API-ல இருக்கு
  • User-defined packages — நாமே create பண்றது

Package Import பண்றது

import keyword use பண்ணி package-ஐ use பண்ணலாம்:

Common Built-in Java Packages

PackageWhat it providesExample classes
java.langCore Java classes — imported automaticallyString, Math, System, Integer
java.utilData structures, date/time, random numbersArrayList, HashMap, Scanner
java.ioReading and writing files / streamsFile, FileWriter, BufferedReader
java.nio.fileModern file & path API (Java 7+)Files, Path, Paths
java.netNetworking — URLs, sockets, HTTPURL, HttpURLConnection
java.sqlDatabase connectivity (JDBC)Connection, Statement, ResultSet
Java reference fragmentJAVA
// Step 1: Declare the package at TOP of file
package com.myapp.utils;

// Step 2: Define your class
public class StringHelper {
    public static String shout(String s) {
        return s.toUpperCase() + "!";
    }
}

// Step 3: Use it elsewhere
import com.myapp.utils.StringHelper;
System.out.println(StringHelper.shout("hello"));  // HELLO!

Java-வில் package ஏன் பயன்படுத்துவோம்?

  1. Program fast-ஆக run ஆக
  2. Related classes-ஐ organize செய்ய மற்றும் name conflicts avoid செய்ய
  3. Memory save செய்ய
  4. Loops faster-ஆக run ஆக
Reveal answer / விடை

Related classes-ஐ organize செய்ய மற்றும் name conflicts avoid செய்ய

Packages related classes-ஐ organize செய்யும், name conflicts avoid செய்யும். `com.company.project.service` போன்ற naming convention follow செய்வது professional Java development-ன் standard.

03 / Read and predict

முழுமையான உதாரணம்

This complete Main.java program focuses on the lesson idea. Reference fragments above may demonstrate individual statements; this example includes the imports, entry point, and supporting types it needs.

Main.java · complete runnable exampleJAVA
import java.util.ArrayList;
public class Main {
    public static void main(String[] args) throws Exception {
        ArrayList<String> topics = new ArrayList<>();
        topics.add("Packages");
        System.out.println(topics.get(0));
    }
}
Predict first. Then reveal the expected output / வெளியீடு
Packages

The output shown was checked by running this complete example. Trace the executed statements in order, then compare with your run.

04 / Learn by changing

Change it. Run it. Understand it.

Load this lesson example into the editor. Change one value or statement, predict the result, then press RUN to execute Java.

Open Java editor ↗
After the editor loads, choose Load this lesson example, then press RUN.

Powered by OneCompiler. Code you run is sent to OneCompiler for execution. For Scanner examples, supply input in the editor I/O panel; for file examples, files exist in its execution environment.

05 / Your turn

நீங்களே முயற்சி செய்யுங்கள்

Practice challenge

Remove the import and replace ArrayList with java.util.ArrayList everywhere in the example.

Reveal the answer and reasoning / விடை

The fully qualified name works without an import. For a local package demo, put package lessons; at the top of Main.java, compile with javac -d . Main.java, and run java lessons.Main.

தவிர்க்க வேண்டிய தவறு: An import is not a dependency download. A third-party library must already be available to the compiler and runtime.

பாடத்தின் சுருக்கம்

  • Explain the example without reading the output first.
  • Make the change requested in the practice task.
  • Describe why the result changed—or why compilation failed.

Ready to move on? Follow the next lesson in course order, or return to the curriculum to review a prerequisite.

Coding Tamilan · Understand the idea. Try the code. Build the habit.