Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures


Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips


Submit News
Search the site here...
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Java: String Overview

JavaFAQ Home » Java Notes by Fred Swartz Go to all tips in Java Notes by Fred Swartz

Bookmark and Share Strings are sequences of Unicode characters. In many programming languages strings are are stored in arrays of characters (eg C, C++, Pascal, ...). However, in Java strings are a separate object type, called String. There is a String class and methods for working with String objects. The "+" operator is used for concatenation, but all other operations on strings are done with methods in the String class.

See the Summary - Strings for an overview of the methods in String and related classes.

Related types and classes

String The basic class for strings. String objects can NOT be changed.
char Primitive type for 16-bit Unicode characters.
Character Primarily useful for its utility functions for working with characters.
StringBuffer StringBuffers are used to build or change strings. Conversion between String and StringBuffer is easy.
StringTokenizer Used to break a String into tokens (words).
Useful for reading and writing text files.
Pattern, Matcher JDK 1.4 added java.util.Pattern and Matcher to do regular expression matching.

String literals

To write a constant string, put the characters between double quotes, eg "abc".

Escape Character

If the string contains double quotes, put a backslash ('') in front of each double quote, eg "abc"def"ghi". The String equivalent of 0, is the string with no characters, "".


1 + 2 3
"1" + 2 "12"
1 + "2" "12"
"1" + 2 + 3"123"
1 + 2 + "3""33"
Putting two strings together to make a third string is called concatenation. In Java the concatenation operator is '+', the same operator as for adding numbers. If either operand is a String, Java will convert the other operand to a String (if possible) and concatenate the two.
 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search

Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy