Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

Java String Introduction

In general, a string is nothing but a sequence of characters identified by double quote(" ").

In java,Programming each string is an object.

Java supports 4-inbuilt classes specifically used to represent and manipulate strings like:
String, StringBuffer, StringBuilder, StringTokenizer.

String Class:

String is an inbuilt class present in java.lang package, specifically used to represent and manipulate strings.
In this context there are two approaches two represent strings which are as followed:

(Approach 1):

  • String s1= “java”;
  • String s2= “race”;
  • String s3= “java”;

(SCP ---  STRING  CONSTANT  POOL)   

(Approach 2):

  • String s1= new string(“java”);
  • String s2= new string (“race”);
  • String s3= new string(“java”);

 

HEAP

SCP

S1_ _ _ _ _

JAVA

JAVA


  • Here, each strings are immutable ( non- changeable behaviour).

 

Example:

String  s1 = “java”;                   
System.out.println(s1.concat(“race”));

Output:  javarace

About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext