Click to Play

Where SES Is Heading
Despite the woes and gloom of the economic downturn, it seems that the search industry maintains high energy and enthusiasm. Speaking specifically about...

Recent Articles

Understanding A Denial Of Service Attack
I heard on the news today that my favorite social network, Twitter, is being plagued by what they called a "denial of service attack". What on Earth is that? They're forced to not actually get service and it's an attack?

Evolving Business And IT Rules To Match New Demand
Michael Cote of Redmonk had a nice piece on over on his People over Process blog. He made a series of great points about the risk of business and IT people not being aligned - risks to the business and to IT.

Google To Enter The OS Market For Netbooks
Google certainly doesn't rest on its laurels, that's for sure. They are, first and foremost a search engine, but the success of their search business has fathered so many products that aren't search related at...

Building And Developing Railo For Testing
As of today, you can easily build your very own version of Railo from the latest source code in Subversion! This blog post will take you through all the steps necessary...

The Truth About Technical Accessibility
This has been stewing for a while. Just brimming under the surface. An brewing anger towards companies that do not understand accessibility, nor the commitment that is required to be accessible, but will give it a light...


08.20.09

Understanding And Implementing JAVA String Methods

By Vaibhav Pandey

Strings are very important part of any programming language.Same is the case with Java.There are so many String methods in String class and it will become difficult to explain all of them.I am mainly focusing on some methods which are worthful to beginners.I will also explain some basics about Strings here which makes Strings easy to understand.So, lets begin.

Basics about Strings in Java

1. You can create Strings in various ways:-

a) By Creating a String Object
String s=new String("abcdef");

b) By just creating object and then referring to string
String a=new String();
a="abcdef";

c) By simply creating a reference variable
String a="abcdef";

2. All the strings gets collected in a special memory are for Strings called " String constant pool".

3. JVM does all string related tasks to avoid the memory wastage for more info on this refer "How JVM Handles strings".

4. Every String is considered as a string literal.

5. Strings are immutable only reference changes string never changes.New string literals are referenced when there is any manipulation.The old string gets lost in the preceding.look below

So Simple, So Smart. Get The Online Backup
That Gives You Both. Download a Free Trial

String s="abcd";

s=s+"efgh";

Important String Methods

Following are most commonly used methods in the String class.

1.public String concat(String s)

This method returns a string with the value of string passed in to the method appended to the end of String which used to invoke the method.

String s="abcdefg";
System.out.println(s.concat("hijlk"));

Note:-Always use assignment operator in case of concat operator otherwise concat will be unreferenced and you will get old String.example

s.concat("hijkl");
System.out.println(s);

It will present output as " abcdefg " different than what we have expected.So always be careful in using the assignment operator in String method calls.

2.public charAt(int index)

This method returns a specific character located at the String's specific index.Remember,String indexes are zero based.Example

String s="Alfanso Mango";
System.out.println(s.charAt(0));

Continue reading this article.


About the Author:
Vaibhav Pandey got offered employment from an Indian Multinational IT Company. He is 21 years old. He has a huge interest in Java programming and has liked it from his study days. Vaibhav loves to blog and share his experiences and thoughts. He now resides in Lucknow, a state capital in India. Check out his blog at http://javatutorialsworld.blogspot.com.
About SysAdminNews
SysAdminNews is a collection of articles, news and commentary designed to keep system administrators informed about the latest trends impacting their profession. Updates and Advice for System Administrators





SysAdminNews is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
SysAdminNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITManagementNews.com





-- SysAdminNews is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2009 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


Database Forum Updates and Advice for System Administrators SysAdminNews News Archives About Us Feedback SysAdminNews.com About Article Archive News Downloads WebProWorld Forums iEntry Advertise Contact Jayde