String Handling in Java

Google Advertisements

Prev Tutorial Next Tutorial

String Handling in Java

The basic aim of String Handling concept is storing the string data in the main memory (RAM), manipulating the data of the String, retrieving the part of the String etc. String Handling provides a lot of concepts that can be performed on a string such as concatenation of string, comparison of string, find sub string etc.

string handling in java

Java String contains an immutable sequence of Unicode characters. Java String is differ from string in C or C++, where (in C or C++) string is simply an array of char. String class is encapsulated under java.lang package.

Immutable class in Java

Immutable class means that once an object is created, we cannot change its content. In Java, . In Java String, Integer, Byte, Short, Float, Double and all other wrapper classes are immutable.

Example of Immutable class in Java

// An immutable class
public final class Student
{
    final String name;
    final int roll_no;
 
    public Student(String name, int roll_no)
    {
        this.name = name;
        this.regNo = roll_no;
    }
    public String getName()
    {
        return name;
    }
    public int getRollNo()
    {
        return roll_no;
    }
}
 
// Driver class
class Result
{
    public static void main(String args[])
    {
        Student s = new Student("Hitesh", 18);
        System.out.println(s.name);
        System.out.println(s.roll_no);
    }
}

Character

It is an identifier enclosed within single quotes (' ').
Example: 'A', '$', 'p'

String:

String is a sequence of characters enclosed within double quotes (" ") is known as String.
Example: "Java Programming".

In java programming to store the character data we have a fundamental datatype called char. Similarly to store the string data and to perform various operation on String data, we have three predefined classes they are:

  • String
  • StringBuffer
  • StringBuilder
Prev Tutorial Next Tutorial

Google Advertisements

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs