Java is a very powerful high-level programming language, Java has a lot of super features. String is a data type in java.
What is String ?
Firstly, String is a data type in java training institute in Chennai as you already know, it has a series of character in (other words)
The number of character in a word is a string. For eg: Say, Good Bye ie. say has 3 characters of string and goodbye is the 7 character of string.
String is an unchangeable object in Java that means it’s a constant object, so you can’t change once it’s fixed.
How to create a String ?
There are only two ways to create a String, one is String literal and another one is by using new keyword.
What is the purpose of String ?
You can’t use character all the time while defining a new object or new method. It also creates a lot of confusion to developers, so avoid these types of error, String is created and its also a family of data type, Core java training in Chennai
String Literal:
String literal is nothing but you are assigning the String to String instance
For eg:
String s1 = “Hi, Good Morning”;
String s2 = “Hi, Good Morning”;
String literal is not a good type to determine to String instance because of the involvement of new you can’t java training institute in Chennai able to create an object. So to avoid these types of errors we are going to use
String using New Keyword:
It's the right approach to define a string.
For Eg:
String s1 = new (“Hi,Good Morning”);
String s2 = new (“Hi,Good Morning”);
String Methods in Java:
1.char charAt(int index)2.boolean equals(Object obj)
3.boolean equalsIgnoreCase(String string)
4.int compareTo(String string)
5.int compareToIgnoreCase(String string)
6.boolean startsWith(String prefix, int offset)
7.boolean startsWith(String prefix)
8.boolean endsWith(String suffix)
9.int hashCode()
10.int indexOf(int ch)
11.int indexOf(int ch, int fromIndex)
12.int lastIndexOf(int ch)
13.int lastIndexOf(int ch, int fromIndex)
14.int indexOf(String str)
15.int lastindexOf(String str)
16.String substring(int beginIndex)
17.String substring(int beginIndex, int endIndex)
18.String concat(String str)
19.String replace(char oldChar, char newChar)
20.boolean contains(CharSequence s)
21.String toUpperCase(Locale locale)
22.String toUpperCase()
23.public String intern()
24.public boolean isEmpty().
25.public static String join() and so on