java.lang.String


 

java.lang.String

java.lang.String class extends from Object(java.lang.Objects) and used to represent the character String.

java.lang.String class extends from Object(java.lang.Objects) and used to represent the character String.

java.lang.String

java.lang.String class extends from Object(java.lang.Objects) and used to represent the character String. Basically, String is a set of alphabet that is constant in nature by default and cann't be changed once created.

String are like array If we write ...

String()

it will construct the new empty string

and if we takes a simple example of String "Hello World", it will begin counting at 0 then 1,2 and so on.

a simple example

String a = "one";

System.out.println("a");

the output is ..

one

String class has following constructor and methods

Java String Constructor

String()

String(byte[] bytes)

String(byte[] ascii, int hibyte)

String(byte[] bytes, int offset, int length)

String(byte[] ascii, int hibyte, int offset, int count)

String(byte[] bytes, int offset, int length, String charsetName)

String(byte[] bytes, String charsetName)

String(char[] value)

String(char[] value, int offset, int count)

String(String original)

String(StringBuffer buffer)

Java String Method

char charAt(int index)

int compareTo(Object o)

int compareTo(String anotherString)

int compareToIgnoreCase(String str)

String concat(String str)

0

boolean contentEquals(StringBuffer sb)

static String copyValueOf(char[] data)

static String copyValueOf(char[] data, int offset, int count)

1

boolean endsWith(String suffix)

boolean equals(Object anObject)

boolean equalsIgnoreCase(String anotherString)

2

byte[] getBytes()

void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)

byte[] getBytes(String charsetName)

3

void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)

int hashCode()

int indexOf(int ch)

4

int indexOf(int ch, int fromIndex)

int indexOf(String str)

int indexOf(String str, int fromIndex)

5

String intern()

int lastIndexOf(int ch)

int lastIndexOf(int ch, int fromIndex)

6

int lastIndexOf(String str)

int lastIndexOf(String str, int fromIndex)

int length()

7

boolean matches(String regex)

boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)

boolean regionMatches(int toffset, String other, int ooffset, int len)

8

String replace(char oldChar, char newChar)

String replaceAll(String regex, String replacement)

String replaceFirst(String regex, String replacement)

9

String[] split(String regex)

String[] split(String regex, int limit)

boolean startsWith(String prefix)

0

boolean startsWith(String prefix, int toffset)

CharSequence subSequence(int beginIndex, int endIndex)

String substring(int beginIndex)

1

String substring(int beginIndex, int endIndex)

char[] toCharArray()

String toLowerCase()

2

String toLowerCase(Locale locale)

String toString()

String toUpperCase()

3

String toUpperCase(Locale locale)

String trim()

static String valueOf(boolean b)

4

static String valueOf(char c)

static String valueOf(char[] data)

static String valueOf(char[] data, int offset, int count)

5

static String valueOf(double d)

static String valueOf(float f)

static String valueOf(int i)

6

static String valueOf(long l)

static String valueOf(Object obj)

java.lang.String Implement the given Interfaces too...

7

CharSequence

Comparable

Serializable

8

You will find more examples about foregoing interfaces in further articles..

More String Articles

Java String Examples

9

Trim String Example

 

Ads