Home Tutorial Java StringExamples java.lang.String


Share on Google+Share on Google+
Posted on: April 6, 2005 at 12:00 AM
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. 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 ...


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";


the output is ..


String class has following constructor and methods

Java String Constructor


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)

boolean contentEquals(StringBuffer sb)

static String copyValueOf(char[] data)

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

boolean endsWith(String suffix)

boolean equals(Object anObject)

boolean equalsIgnoreCase(String anotherString)

byte[] getBytes()

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

byte[] getBytes(String charsetName)

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

int hashCode()

int indexOf(int ch)

int indexOf(int ch, int fromIndex)

int indexOf(String str)

int indexOf(String str, int fromIndex)

String intern()

int lastIndexOf(int ch)

int lastIndexOf(int ch, int fromIndex)

int lastIndexOf(String str)

int lastIndexOf(String str, int fromIndex)

int length()

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)

String replace(char oldChar, char newChar)

String replaceAll(String regex, String replacement)

String replaceFirst(String regex, String replacement)

String[] split(String regex)

String[] split(String regex, int limit)

boolean startsWith(String prefix)

boolean startsWith(String prefix, int toffset)

CharSequence subSequence(int beginIndex, int endIndex)

String substring(int beginIndex)

String substring(int beginIndex, int endIndex)

char[] toCharArray()

String toLowerCase()

String toLowerCase(Locale locale)

String toString()

String toUpperCase()

String toUpperCase(Locale locale)

String trim()

static String valueOf(boolean b)

static String valueOf(char c)

static String valueOf(char[] data)

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

static String valueOf(double d)

static String valueOf(float f)

static String valueOf(int i)

static String valueOf(long l)

static String valueOf(Object obj)

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




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

More String Articles

Java String Examples

Trim String Example



Related Tags for java.lang.String:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 6, 2005

Recommend the tutorial

Advertisements Advertisements