JAVA String
In Java there is eight primitive data type and also a special String class in java.lang.string package for string handling.
String are like sequence of characters. String is not a primitive data type (because strings are objects) but the java language provides some special support to strings so, sometimes its seems like Strings are one of the primitive type.
String are very widely used in java and if you ever done some programming in Java than you must have created a string in some way or the other.
For example the most direct way to create an String object is by just enclosing some characters in double quotes("").
String is an object in java so it can also be declared as any other object is declared using new keyword.
String class has several constructors to create a String object. The above example is one of the way simplest way to create an string. The constructor used in the example is a no argument constructor or we can say a default constructor which will create a empty String i.e. str will be an instance of String with no character in it.
Below is an example which show a number of ways to create a String object.
Output of Program:
There are some more String Constructors but we will discusses them in later tutorials.
Methods of String Class:- String class provides several methods for string manipulation and these are going to be very useful in many situation like Input validation, text analysis and file conversions etc. In this tutorial we are going to discuses most of the common methods of String class.
String are like sequence of characters. String is not a primitive data type (because strings are objects) but the java language provides some special support to strings so, sometimes its seems like Strings are one of the primitive type.
String are very widely used in java and if you ever done some programming in Java than you must have created a string in some way or the other.
For example the most direct way to create an String object is by just enclosing some characters in double quotes("").
String str ="This is a String"; |
String is an object in java so it can also be declared as any other object is declared using new keyword.
String str = new String(); |
String class has several constructors to create a String object. The above example is one of the way simplest way to create an string. The constructor used in the example is a no argument constructor or we can say a default constructor which will create a empty String i.e. str will be an instance of String with no character in it.
Below is an example which show a number of ways to create a String object.
public class StringExample { public static void main(String[] args) { //Creating an array using byte array of ASCII Value String strByte = new String(b); |
Output of Program:
There are some more String Constructors but we will discusses them in later tutorials.
Methods of String Class:- String class provides several methods for string manipulation and these are going to be very useful in many situation like Input validation, text analysis and file conversions etc. In this tutorial we are going to discuses most of the common methods of String class.
- public charAt(int index) :-
- public int length() :-
- public String concat(String s) :-
- public boolean equals(String s)
- public boolean equalsIgnoreCase(String s)
- public String substring(int begin)
- public String substring(int begin,int end)
- public String toLowerCase()
- public String toUpperCase()
- public String trim()
- public int indexOf(int ch)
- public int indexOf(int ch, int startIndex)
- public int indexOf(String str)
- public int indexOf(String str, int startIndex)
Hеllο to every bοԁy, іt's my first pay a visit of this website; this webpage contains awesome and actually fine stuff designed for readers.
ReplyDeleteHere is my weblog; hydroxatone
I ωas suggestеd this website by
ReplyDeletemeаns of my cousіn. I'm now not certain whether or not this submit is written via him as no one else realize such special approximately my problem. You're inсredible!
Thanks!
Feel fгеe to surf to mу wеb pаge .
.. hydroxatone
What's up i am kavin, its my first occasion to commenting anyplace, when i read this post i thought i could also make comment due to this brilliant paragraph.
ReplyDeleteFeel free to surf to my blog post ... luminess air
Dοеs your blog havе a contact page?
ReplyDeleteI'm having trouble locating it but, I'd like tο shоot уοu an e-mаil.
I've got some creative ideas for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it grow over time.
My web blog ... airbrush makeup reviews
Hi there, I check your blogs on a regular basis.
ReplyDeleteYour story-telling style is awesome, keep doing what you're doing!
Also visit my web page perfect waist to hip ratio
I rarely leave a response, but i did some searching and wound up here "JAVA Programming : String Class".
ReplyDeleteAnd I actually do have 2 questions for you if you don't mind. Could it be simply me or does it look like a few of these comments come across like they are left by brain dead individuals? :-P And, if you are posting on other sites, I would like to follow anything new you have to post. Would you list of every one of your communal sites like your twitter feed, Facebook page or linkedin profile?
my site :: Skin care
Hello there! This is my first comment here so I just wanted to give a quick shout out and say
ReplyDeleteI genuinely enjoy reading through your articles.
Can you suggest any other blogs/websites/forums that go over
the same subjects? Thanks a ton!
Also visit my blog Xtrasize Supplement
Thanks for your personal marvelous posting! I really enjoyed reading it, you can be a great author.
ReplyDeleteI will ensure that I bookmark your blog and definitely will
come back later on. I want to encourage you to definitely continue your great writing,
have a nice morning!
My weblog ... Le parfait skin
Increasingly men and women are adopting this technique which they're finding really very simple to practice.
ReplyDeleteFeel free to visit my web blog - Https://www.privly.org/
Great blog you have here.. It's difficult to find good quality writing like yours nowadays. I honestly appreciate people like you! Take care!!
ReplyDeleteHere is my web blog Beta Force Muscle
Simply want to say your article is as astounding.
ReplyDeleteThe clearness for your post is just excellent and i can think you're an expert on this subject. Fine with your permission let me to seize your feed to keep up to date with coming near near post. Thank you a million and please keep up the gratifying work.
My homepage; Download Muscle Maximizer
Thank you for some other great post. The place else may just anybody
ReplyDeleteget that type of info in such a perfect way of writing? I
have a presentation next week, and I am at the look
for such info.
Feel free to surf to my website ... Xtrasize Review
Quality content is the secret to interest the viewers to visit the web site,
ReplyDeletethat's what this website is providing.
Here is my webpage ... Garcinia Cambogia
This web site definitely has all the information and facts
ReplyDeleteI needed concerning this subject and didn't know who to ask.
Also visit my blog: Saphire Ecig Review
It's amazing in favor of me to have a website, which is good designed for my knowledge. thanks admin
ReplyDeletemy blog ... anti cellulite treatment
Awesome! Its really amazing article, I have got much clear idea regarding from this
ReplyDeletepost.
my blog post: Le Parfait Reviews
Please let me know if you're looking for a author for your weblog. You have some really great posts and I feel I would be a good asset. If you ever want to take some of the load off, I'd
ReplyDeletelove to write some content for your blog in exchange for a link back to mine.
Please send me an e-mail if interested.
Cheers!
Feel free to visit my web site - garcinia cambogia weight loss
Great website for Java Programming.Please try to include more topics on Java Programming. The topic explanation is very good.
ReplyDeleteThanks for the information.I really need that information.It's helps me to learn new things. I want to be like you. keep posting new article . I'm your fan your article...
ReplyDeleteCorporate Training Company for Testing
thanks for sharing this information
ReplyDeletedata science classroom training in bangalore
devops certification course in bangalore
devops training institutes in bangalore
aws certification course in bangalore
best AWS Training institute in Bangalore
Amazon web services training in bangalore
thanks for sharing this post
ReplyDeleteaws training center in chennai
aws training in chennai
aws training institute in chennai
best python training in chennai
best angularjs training in chennai
angular js training in sholinganallur
angularjs training in chennai
SAP S/4HANA provides businesses with a wide range of collaboration options that can help them streamline their operations, reduce costs, and improve customer satisfaction. From procurement and finance to supply chain and sales, SAP S/4HANA offers a comprehensive set of collaboration tools that can help businesses stay ahead of the competition and drive growth in the digital age. For more information, visit our website SAP Consulting Services or call us @ 1-289-952-8845.
ReplyDelete