Java Data Types — தமிழ்

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

Java Data Types

Choose a type that fits the value.

Step-by-step explanationsRunnable JavaPractice + answer

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

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

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

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

Types define which values a variable can hold and which operations make sense. Use int for ordinary whole numbers, double for many decimal calculations, boolean for true/false decisions, and String for text. These examples are a starting point, not a replacement for considering precision and range in a real application.

02 / Step by step

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

Java Data Types

முந்தைய chapter-ல பார்த்தோம் — Java-ல variable declare பண்ணும்போது data type specify பண்றது அவசியம்:

Data types இரண்டு groups-ஆ பிரியும்:

  • Primitive data types — byte, short, int, long, float, double, boolean, char
  • Non-primitive data types — String, Arrays, Classes (பிறகு பார்க்கலாம்)

Primitive Data Types

Primitive type 8 வகை இருக்கு. இதை புரிஞ்சுக்க 'Boxes' (பெட்டிகள்) உதாரணத்தை எடுத்துப்போம். சின்ன பொருளை வையுங்கள்க்க சின்ன பெட்டி போதும், பெரிய பொருளுக்கு பெரிய பெட்டி வேணும் இல்லையா? அதே போல தான் Data Types!

Data TypeSizeவிளக்கம்
byte1 byteமிகச்சிறிய பெட்டி (உதா: ஒரு மனிதனின் வயது 0-100)
short2 bytesசிறிய பெட்டி (உதா: ஒரு ஊரின் மக்கள் தொகை)
int4 bytesநடுத்தர பெட்டி (உதா: YouTube video views)
long8 bytesமிகப்பெரிய பெட்டி (உதா: பிரபஞ்சத்தின் தூரம்)
float4 bytesபுள்ளி வையுங்கள்த்த எண்கள் (Decimal) – 6 முதல் 7 digits துல்லியம்
double8 bytesபுள்ளி வையுங்கள்த்த எண்கள் (Decimal) – 15 digits அதிக துல்லியம் (உதா: Bank Balance)
boolean1 bittrue அல்லது false மட்டுமே
char2 bytesSingle character அல்லது ASCII value

Decimal numbers-க்கு double-ஐதான் prefer பண்றோம் — ஏன்னா float-ஐ விட precise-ஆ இருக்கும்.

Java reference fragmentJAVA
byte   small  = 127;              // -128 to 127
short  medium = 32767;            // -32,768 to 32,767
int    num    = 2_000_000;        // underscores for readability
long   big    = 9_876_543_210L;   // append L
float  price  = 9.99f;            // append f
double pi     = 3.14159265358979;
boolean flag  = true;
char   ch     = 'J';

System.out.println(Integer.MAX_VALUE);       // 2147483647
System.out.println(Character.isLetter(ch));  // true

Java-வில் decimal numbers-க்கு எந்த data type prefer செய்வோம்?

  1. float
  2. int
  3. double
  4. long
Reveal answer / விடை

double

`double` என்பது 15 digits precision கொடுக்கும். `float` 6-7 digits மட்டுமே. Bank calculations, scientific values-க்கு `double` அவசியம்.

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
public class Main {
    public static void main(String[] args) throws Exception {
        int seats = 24;
        double temperature = 28.5;
        boolean open = true;
        char section = 'A';
        String place = "Ariyalur";
        System.out.println(seats + " | " + temperature + " | " + open);
        System.out.println(section + " | " + place);
    }
}
Predict first. Then reveal the expected output / வெளியீடு
24 | 28.5 | true
A | Ariyalur

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

Add a long variable called views with value 3000000000L, then print it.

Reveal the answer and reasoning / விடை

Use long views = 3000000000L; and System.out.println(views);. The L suffix makes this literal a long.

தவிர்க்க வேண்டிய தவறு: char uses single quotes for one UTF-16 code unit; String uses double quotes for text. Integer overflow is not automatically reported as a compilation error.

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

  • 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.