Java Strings — தமிழ்

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

Java Strings

Work with text, one operation at a time.

Step-by-step explanationsRunnable JavaPractice + answer

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

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

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

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

A String holds text. String objects are immutable: operations such as toUpperCase return another String rather than changing the original object. Use equals for content comparisons, and check the bounds before requesting a substring.

02 / Step by step

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

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

Strings என்பது characters-ஓட sequence — text-ஐ store பண்ணவும் manipulate பண்ணவும் use ஆகுது.

Java-ல String double quotes-க்கு உள்ளே இருக்கும்:

String Length

String-ஓட length தெரிஞ்சுக்க length() method பயன்படுத்தலாம்:

Useful String Methods

  • toUpperCase() — எல்லா letters-உம் uppercase ஆகும்
  • toLowerCase() — எல்லா letters-உம் lowercase ஆகும்
  • indexOf() — குறிப்பிட்ட character-ஓட position கொடுக்கும்
  • concat() — இரண்டு strings-ஐ join பண்றதுக்கு
  • trim() — ஆரம்பம் மற்றும் முடிவுல இருக்குற spaces remove ஆகும்
  • replace() — ஒரு value-ஐ இன்னொரு value-ஆ மாத்துது

String Concatenation

Strings-ஐ + operator use பண்ணி join பண்ணலாம்:

String-ஐ number-உடன் add பண்ணா, result string ஆகும் — numeric addition நடக்காது.

Java reference fragmentJAVA
String s = "Hello, Java!";
System.out.println(s.length());           // 12
System.out.println(s.toUpperCase());      // HELLO, JAVA!
System.out.println(s.substring(7, 11));   // Java
System.out.println(s.contains("Java"));   // true
System.out.println(s.replace("Java", "World")); // Hello, World!
System.out.println(s.charAt(0));          // H

// Comparing — always use .equals()
String a = "hello", b = "hello";
System.out.println(a.equals(b));                  // true ✓
System.out.println(a.equalsIgnoreCase("HELLO")); // true

Loop-க்கு உள்ளே String Concatenation avoid செய்யவும்: str = str + value என்று loop-ல் use செய்தால் ஒவ்வொரு iteration-லும் புதிய String object create ஆகும் — memory waste! இதற்கு பதில் StringBuilder பயன்படுத்தவும்: StringBuilder sb = new StringBuilder(); பிறகு sb.append(value); — இது production code-ல் ஒரு standard practice.

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 {
        String topic = "Java";
        System.out.println(topic.toUpperCase());
        System.out.println(topic);
        System.out.println(topic.equals("Java"));
        System.out.println(topic.length());
    }
}
Predict first. Then reveal the expected output / வெளியீடு
JAVA
Java
true
4

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

Store the result of toUpperCase back into topic and print it again.

Reveal the answer and reasoning / விடை

Use topic = topic.toUpperCase();. Subsequent reads of topic now refer to the uppercase String.

தவிர்க்க வேண்டிய தவறு: == checks object-reference identity for Strings. It is not the usual way to compare their text.

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

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