<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Java Programming Forum - Learn Java Programming - Blogs - Java String</title>
		<link>http://www.java-forums.org/blogs/java-string/</link>
		<description>Java Programming Forum - Learning Java easily</description>
		<language>en</language>
		<lastBuildDate>Fri, 24 May 2013 07:01:31 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.java-forums.org/images/misc/rss.jpg</url>
			<title>Java Programming Forum - Learn Java Programming - Blogs - Java String</title>
			<link>http://www.java-forums.org/blogs/java-string/</link>
		</image>
		<item>
			<title>Java String comparison with the compareTo method</title>
			<link>http://www.java-forums.org/blogs/java-string/1297-java-string-comparison-compareto-method.html</link>
			<pubDate>Thu, 26 Apr 2012 17:02:14 GMT</pubDate>
			<description>Also a less common 3rd way for comparison of the Java Strings is present. That method is CompareTo method, with string class. In case of two similar...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Also a less common 3rd way for comparison of the Java Strings is present. That method is CompareTo method, with string class. In case of two similar Java Strings, this method will be returning a zero value. String Comparison approach shall look like this given example:<br />
 <br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String string1 = &quot;foo bar&quot;;
String string2 = &quot;foo bar&quot;;

// java string compare example
if (string1.compareTo(string2) == 0)
{
  // this line WILL print
  System.out.println(&quot;The two strings are the same.&quot;)
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1297-java-string-comparison-compareto-method.html</guid>
		</item>
		<item>
			<title>equalsIgnoreCase method</title>
			<link>http://www.java-forums.org/blogs/java-string/1296-equalsignorecase-method.html</link>
			<pubDate>Thu, 26 Apr 2012 17:01:27 GMT</pubDate>
			<description>It shall be ignore in Java string comparison tests that whether strings are uppercase of lowercase. Use EqualsIgnoreCase mthods for equality so that...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">It shall be ignore in Java string comparison tests that whether strings are uppercase of lowercase. Use EqualsIgnoreCase mthods for equality so that to test the strings .<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String string1 = &quot;foo&quot;;
String string2 = &quot;FOO&quot;;

// java string compare while ignoring case
if (string1.equalsIgnoreCase(string2))
{
  // this line WILL print
  System.out.println(&quot;Ignoring case, the two strings are the same.&quot;)
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1296-equalsignorecase-method.html</guid>
		</item>
		<item>
			<title>Java String comparison with the equals method</title>
			<link>http://www.java-forums.org/blogs/java-string/1295-java-string-comparison-equals-method.html</link>
			<pubDate>Thu, 26 Apr 2012 17:00:40 GMT</pubDate>
			<description>About 95% of time, I prefer comparing strings by using Java String class’ equal methods. It is shown below: 
 
if (string1.equals(string2)) 
String...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">About 95% of time, I prefer comparing strings by using Java String class’ equal methods. It is shown below:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">if (string1.equals(string2))</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 String equal method observes if exactly similar string of characters are present in Java strings, they would be considered as equal. <br />
Quick String comparison could be observed, with equal method, 2 strings wouldn’t be equal as same characters are not present.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String string1 = &quot;foo&quot;;
String string2 = &quot;FOO&quot;;

if (string1.equals(string2))
{
  // this line will not print because the
  // java string equals method returns false:
  System.out.println(&quot;The two strings are the same.&quot;)
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 When exactly similar character’s string is present in two strings it means String equal method would be returned as true. For example:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">String string1 = &quot;foo&quot;;
String string2 = &quot;foo&quot;;

// test for equality with the java string equals method
if (string1.equals(string2))
{
  // this line WILL print
  System.out.println(&quot;The two strings are the same.&quot;)
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1295-java-string-comparison-equals-method.html</guid>
		</item>
		<item>
			<title>Java String compare to determine Equality</title>
			<link>http://www.java-forums.org/blogs/java-string/1294-java-string-compare-determine-equality.html</link>
			<pubDate>Thu, 26 Apr 2012 16:59:46 GMT</pubDate>
			<description>Comparison of the java string could be done in various ways, as given below. It is dependent upon javastringcompare type that which of them will be...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Comparison of the java string could be done in various ways, as given below. It is dependent upon javastringcompare type that which of them will be used.<br />
* == Operator<br />
* equals method<br />
* compareTo method<br />
Comparing, by using the “== Operator”<br />
When String object references are compared, ==operator is used. If 2 variables of String are pointed towards similar object present in memory, then comparison will be returned true. In other case it will return false. It shall be noted that ==operator is not for comparison of the text content which is present in String objects. Just the two string references are compared by it. Given program will be printing “strings are not equal”, in first case. Otherwise, “strings are equal” in 2nd one.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1294-java-string-compare-determine-equality.html</guid>
		</item>
		<item>
			<title>Compare strings</title>
			<link>http://www.java-forums.org/blogs/java-string/1293-compare-strings.html</link>
			<pubDate>Thu, 26 Apr 2012 16:58:47 GMT</pubDate>
			<description>Two strings comparison will be learnt in this section. Java lang package gives methods for comparison of 2 with either lower or upper case. Facility...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Two strings comparison will be learnt in this section. Java lang package gives methods for comparison of 2 with either lower or upper case. Facility is being provided by the equals() method to compare 2 strings. Equal() methods are used by the given program to help you for comparing 2 strings. In case when both of the strings present are equal then a message “Given strings equal” would be displayed. Otherwise, “given strings unequal” would be shown.<br />
Description of code:<br />
equals():<br />
<br />
This method is used for comparison of the object values. Also, Boolean type values are returned either as false or true. If true is returned for objects then it means it is equal, otherwise not.<br />
Code is given below for this program:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">import java.lang.*;
import java.io.*;

public class CompString{
  public static void main(String&#91;&#93; args) throws IOException{
  System.out.println(&quot;String equals or not example!&quot;);
  BufferedReader bf = 
new BufferedReader(new InputStreamReader(System.in));
  System.out.println(&quot;Please enter first string:&quot;);
  String str1 = bf.readLine();
  System.out.println(&quot;Please enter second string:&quot;);
  String str2 = bf.readLine();
  if (str1.equals(str2)){
  System.out.println(&quot;The given string is equals&quot;);
  }
  else{
  System.out.println(&quot;The given string is not equals&quot;);
  }
  }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1293-compare-strings.html</guid>
		</item>
		<item>
			<title>Convert String to Number</title>
			<link>http://www.java-forums.org/blogs/java-string/1292-convert-string-number.html</link>
			<pubDate>Thu, 26 Apr 2012 16:57:53 GMT</pubDate>
			<description>This section shows how Number is converted into String. Functionaliy is provided by this program for conversion of String into Number, 
Code...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">This section shows how Number is converted into String. Functionaliy is provided by this program for conversion of String into Number,<br />
Code Description:<br />
In this program, String os Boolean, int, byte, double is being taken as it is given below. Also, MIN_VALUE and MIN_VALUE methods are used which are different wrapper classes so that all values on double, short and int could be printed.<br />
Here is the code used:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public class StrToNum{
  public static void main (String args&#91;&#93;){
  String table = &quot;Table of the Java Numbers\n&quot; +
 &quot;Primitive Type\tSize in Bits\tTypical Value\tMinimum Value
\tMaximum Value\n&quot; +
 &quot;**************\t**************\t**************\t**********
****\t**************\n&quot;;
  
  // int
  table += &quot;int\t\t&quot; + 32 + &quot;\t\t&quot; + 65536 + &quot;\t\t&quot; + Integer.MIN_VALUE
 + &quot;\t&quot; + Integer.MAX_VALUE + &quot;\n&quot;;
  // byte
  table += &quot;byte\t\t&quot; + 8 + &quot;\t\t&quot; + (byte)5 + &quot;\t\t&quot; + Byte.MIN_VALUE 
+ &quot;\t\t&quot; + Byte.MAX_VALUE + &quot;\n&quot;;
  // short
  table += &quot;short\t\t&quot; + 16 + &quot;\t\t&quot; + (short)1024 + &quot;\t\t&quot; + Short.MIN_VALUE
 + &quot;\t\t&quot; + Short.MAX_VALUE + &quot;\n&quot;;
  //boolean
  table += &quot;boolean\t\t&quot; + &quot;\t\t&quot; + true + ',' + false + &quot;\t\t&quot; + &quot;\n&quot;;
  // double
  table += &quot;double\t\t&quot; + 64 + &quot;\t\t&quot; + 100e100 + &quot;\t\t&quot; + Double.MIN_VALUE +
 &quot;\t&quot; + Double.MAX_VALUE + &quot;\n&quot;;
  table +=
 &quot;**************\t**************\t**************\t***************\t************\n&quot;;

  System.out.println(table);
}
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1292-convert-string-number.html</guid>
		</item>
		<item>
			<title>Convert Number to String</title>
			<link>http://www.java-forums.org/blogs/java-string/1291-convert-number-string.html</link>
			<pubDate>Thu, 26 Apr 2012 16:56:53 GMT</pubDate>
			<description>This sections shows how numbers can be converted into String. Given program gives the functionality for conversion of numbers to String. 
 
*Code...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">This sections shows how numbers can be converted into String. Given program gives the functionality for conversion of numbers to String.<br />
<br />
<b>Code Description:</b><br />
Different kind of numbers have been declared, for example, long, int and float etc given below. valueOf() method is used which is basically Stringclass’s method. For numeric conversions String.valueOf() is used &amp; numeric classes are converted into String by using toString() method, as given below:<br />
Program’s code is given below:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">class NumToStr {
  public static void main(String&#91;&#93; args) {
  int i  = 40;
  float f  = (float) 100.0;
  long l = 3000000;
  String s = new String();

  s = String.valueOf(i);
  System.out.println (&quot;int i = &quot; + s);
  s = String.valueOf(f);
  System.out.println (&quot;float f = &quot; + s);
  s = String.valueOf(l);
  System.out.println (&quot;long l = &quot; + s);
  s = new Integer(i).toString();
  System.out.println (&quot;int i = &quot; + s);
  s = new Float(f).toString();
  System.out.println (&quot;float f = &quot; + s);
  s = new Long(l).toString();
  System.out.println (&quot;long l = &quot; + s);
  }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1291-convert-number-string.html</guid>
		</item>
		<item>
			<title>Regular Expressions, Literal Strings and Backslashes</title>
			<link>http://www.java-forums.org/blogs/java-string/1290-regular-expressions-literal-strings-backslashes.html</link>
			<pubDate>Thu, 26 Apr 2012 16:55:48 GMT</pubDate>
			<description>In literal strings, backlash is considered as escape character. It is basically a single backlash i.e. “\\”. Backlash is also considered an escape...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">In literal strings, backlash is considered as escape character. It is basically a single backlash i.e. “\\”. Backlash is also considered an escape character in case of regular expressions. A single backlash is matched to the regular expression \\. As a java string, regular expression would become “\\\\”. Four backlashes are used for matching just one single.<br />
<br />
Word character is being matched with regex \w. It is abbreviated as &quot;\\w&quot;.<br />
<br />
Similar backlash mess up occurs, when replacement strings are provided for the methods, for example String.replaceAll() in your java code. In case of replacement text it is necessary to encode dollar sign as \$, or backlas as \\ when regex match is required to be replaced with backlash or dollar sign. In literal java strings, it is necessary to escape the backlashes. Hence in replacement text dollar sign would become \\$, when it is being written as literal string. One backlash would become \\\\. Four backlases are used for insertion of single one.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1290-regular-expressions-literal-strings-backslashes.html</guid>
		</item>
		<item>
			<title>Java Matcher Class</title>
			<link>http://www.java-forums.org/blogs/java-string/1289-java-matcher-class.html</link>
			<pubDate>Thu, 26 Apr 2012 16:54:55 GMT</pubDate>
			<description>Matcher class instances match the character sequences, against string pattern. Matchers are provided with input by CharSequence so that to provide...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Matcher class instances match the character sequences, against string pattern. Matchers are provided with input by CharSequence so that to provide support to matching, against characters from input sources.<br />
<br />
Pattern helps to create the matcher when pattern’s matcher method is invoked. Once it has been made, different match operations could be performed by matcher.<br />
<ul><li style="">Whole input sequence is matched by the matcher method against the pattern.</li><li style="">Input sequence is matched by the lookingAt method against the pattern.</li><li style="">Input sequence is scaned by the final method, which is looked for the proceding sequence which will be matching the pattern,</li></ul><br />
<br />
<br />
A Boolean is returned by these methods which indicate the failure or success. Details regading successful match may be obtained when the state of matcher is being queried.<br />
<br />
Methods are also defined by this class to replace the matched sequences, by new string. Content of them could be computed by the help of match result.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1289-java-matcher-class.html</guid>
		</item>
		<item>
			<title>Java Pattern Class</title>
			<link>http://www.java-forums.org/blogs/java-string/1288-java-pattern-class.html</link>
			<pubDate>Thu, 26 Apr 2012 16:54:02 GMT</pubDate>
			<description>Pattern class instance presents the regular expression which has been specified in string form, in syntax, same as used by Perl. 
 
Regular...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Pattern class instance presents the regular expression which has been specified in string form, in syntax, same as used by Perl.<br />
<br />
Regular expression shall be compiling first to the Pattern class instance. Matcher object is created by ther resulting pattern, which matches with the sequence of the arbitrary character. Similar patterns are shared by various matchers as it is stateless.<br />
<br />
Given regular expression is compiled by the compile method into a pattern. After this, matcher is created by the matcher method which matches to the given input, against pattern. Regular expression is returned by the pattern method, from which pattern got compiled.<br />
<br />
Split method is considered as a convenience method which makes the given input sequence to be split around this pattern’s matches.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">import java.util.regex.*;

public class Splitter {
    public static void main(String&#91;&#93; args) throws Exception {
        // Create a pattern to match breaks
        Pattern p = Pattern.compile(&quot;&#91;,\\s&#93;+&quot;);
        // Split input with the pattern
        String&#91;&#93; result = 
                 p.split(&quot;one,two, three   four ,  five&quot;);
        for (int i=0; i&lt;result.length; i++)
            System.out.println(result&#91;i&#93;);
    }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1288-java-pattern-class.html</guid>
		</item>
		<item>
			<title>Pattern Method Equivalents in java.lang.String</title>
			<link>http://www.java-forums.org/blogs/java-string/1287-pattern-method-equivalents-java-lang-string.html</link>
			<pubDate>Thu, 26 Apr 2012 16:53:09 GMT</pubDate>
			<description>Support of the regular expression is also present in java.lang.String via different methods which mimic the java.util.regex.Pattern behavior. From...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Support of the regular expression is also present in java.lang.String via different methods which mimic the java.util.regex.Pattern behavior. From APIs, their key excerpts are shown below for convenience.<br />
<br />
<b>Public Boolean matches (String regex): </b><br />
Show whether string will be matching with the regular expression or not. This method’s invocation of the form str.matches produces similar output that was produced by expression Pattern.matches.<br />
<br />
<b>Public string[] split (String regex,int limit): </b><br />
This string is being split around given regular expression matches. This method’s invocation of form str.split produces similar output that was produced by expression Pattern.compiler (regex).split(str, n).<br />
<br />
<b>Public String[] split (String regex): </b><br />
This string is being split around given regular expression matches. This method is same like the 2 argument split method invoked along with given expressions, &amp; limited argument of 0.<br />
Also, a replace method is present which makes the replacement of 1 CharSequence with the other:<br />
<br />
<b>Public String Replace (CharSequence target, CharSequence replacement): </b><br />
String’s every substring is replaced which matched the literal target sequence, along with literal replacement sequence. Replacement takes place from start to end of string.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1287-pattern-method-equivalents-java-lang-string.html</guid>
		</item>
		<item>
			<title>Java String Boundary Matchers</title>
			<link>http://www.java-forums.org/blogs/java-string/1286-java-string-boundary-matchers.html</link>
			<pubDate>Thu, 26 Apr 2012 16:51:30 GMT</pubDate>
			<description>Till now we were just interested in this thing that if match is present at a location in some specified string. Care hs never been taken regarding...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Till now we were just interested in this thing that if match is present at a location in some specified string. Care hs never been taken regarding the location of match in the string, where it actually took place.<br />
<br />
Pattern matches could be made much more precise just by making information specific along with boundary matches. Let us say, e.g, may be one of you are more keen to find out a specific word but only when it is present at start or end of line. May be you desire to be aware of the fact whether matching is being done at word boundary or at previous match’s end.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1286-java-string-boundary-matchers.html</guid>
		</item>
		<item>
			<title>Differences Among Greedy, Reluctant, and Possessive Quantifiers</title>
			<link>http://www.java-forums.org/blogs/java-string/1285-differences-among-greedy-reluctant-possessive-quantifiers.html</link>
			<pubDate>Thu, 26 Apr 2012 16:50:45 GMT</pubDate>
			<description>Subtle difference is present b/w reluctant, greedy and possessive quantifiers. 
 
Greedy ones are known as greedy as they enforce matchers to eat or...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Subtle difference is present b/w reluctant, greedy and possessive quantifiers.<br />
<br />
Greedy ones are known as greedy as they enforce matchers to eat or read in the whole input string before the 1st match attempt. When 1st attempt of match gets failed, input string is back offed by the matcher by 1 character and then tries once again in which the process is repeated till the match is being found or no more characters have been left for backing off. It totally depends upon quantifier that was used in expression to try and match again one or zero characters.<br />
<br />
However, reluctant quantifiers go other way round in which they take their start from input string beginning. After that, they eat reluctantly 1 character at matching time. Last thing is whole input string try.<br />
<br />
Possessive quantifiers usually eat the whole input string and they just try once for matching. They never get back off and if they try to do so, it will permit whole match to get succeeded.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1285-differences-among-greedy-reluctant-possessive-quantifiers.html</guid>
		</item>
		<item>
			<title>Java String Quantifiers</title>
			<link>http://www.java-forums.org/blogs/java-string/1284-java-string-quantifiers.html</link>
			<pubDate>Thu, 26 Apr 2012 16:49:26 GMT</pubDate>
			<description>Number of occurrences are specified by the quantifiers so that to match. For sake of convenience, Pattern API has been divided into 3 sections with...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Number of occurrences are specified by the quantifiers so that to match. For sake of convenience, Pattern API has been divided into 3 sections with specifications that describe possessive, greedy and reluctant quantifiers are represented below. In first look, this might happen that X?+, X? And X?? Be doing similar things as all of them promise to be match X i.e once, or not at all. Subtle differences of implementations are present that will be discussed at the end of this section.<br />
<br />
<div style="text-align: center;"><img src="http://www.java-forums.org/attachments/java-software/3644d1335458944-jclaim-4-4-34-1.jpg" border="0" alt="Name:  1.jpg
Views: 84
Size:  23.1 KB" class="thumbnail" style="float:CONFIG" /><br />
<b>Java String Quantifiers</b></div><br />
Let us start with greedy quantifiers by making 3 varying regular expressions; Letter “a” which is being followed either by + or ? or *. Now let us observe that what happens when expressions are being tested for “” i.e. empty input string.<br />
 <br />
Enter your regex: a?<br />
Enter input string to search: <br />
I found the text &quot;&quot; starting at index 0 and ending at index 0.<br />
<br />
Enter your regex: a*<br />
Enter input string to search: <br />
I found the text &quot;&quot; starting at index 0 and ending at index 0.<br />
<br />
Enter your regex: a+<br />
Enter input string to search: <br />
No match found.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1284-java-string-quantifiers.html</guid>
		</item>
		<item>
			<title>What are Metacharacters</title>
			<link>http://www.java-forums.org/blogs/java-string/1283-what-metacharacters.html</link>
			<pubDate>Thu, 26 Apr 2012 16:47:32 GMT</pubDate>
			<description>Special characters are also supported by this API which places an affect at the mode by which a pattern is matched. Regular expressions can be...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Special characters are also supported by this API which places an affect at the mode by which a pattern is matched. Regular expressions can be changed to cat. &amp; input string to tocats. Output will be as following:<br />
Enter regex i.e. cat.<br />
<br />
Enter “input string” for searching i.e. cats<br />
Text cats are found that start at index zero &amp; end at index four.<br />
Match succeeds even dot is absent in input string. Match succeeds as dots are metacharacters, a character that has special kind of meaning that a match interprets. Metacharacter dot is any character and this is why match succeeded in given example.<br />
API supports the metacharacters which are: &lt;([{\^-=$!|]})?*+.&gt;<br />
<br />
Two methods for enforcing metacharacter to be taken as ordinary character are as following;<br />
•	Preceding of the metacharacter, with a backslash<br />
•	Enclosing it in \Q (that begins the quote), &amp; \E (that ends the quote).<br />
When this technique is used, the \E and \Q might be placed anywhere in expression. The only condition is that \Q shall come first.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1283-what-metacharacters.html</guid>
		</item>
		<item>
			<title>String Literals</title>
			<link>http://www.java-forums.org/blogs/java-string/1282-string-literals.html</link>
			<pubDate>Thu, 26 Apr 2012 16:46:47 GMT</pubDate>
			<description>Basic pattern matching form that is being supported by API is string literal match. E.g, when regular expression and input string is foo, matching...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Basic pattern matching form that is being supported by API is string literal match. E.g, when regular expression and input string is foo, matching succeeds as strings are same. Test harness could be used to try it.<br />
 <br />
Enter regex: foo<br />
Enter “input string” for search: foo<br />
Text foo is found that starts at index 0, &amp; ends at index 3.<br />
<br />
Match was successful. It shall be noted that when input strings are three characters longer then starting index is zero and ending index is three. Beginning index include ranges and end index are exclusive of it, as following:<br />
<br />
Every character that is present in string is present in own clee along with index that positions pointing b/w every cell. Foo string begins at o and ends at 3 index even characters just occupy zero, one and two.<br />
Overlap will be noticed along with subsequent match; Next match’s start index is same as previous match’s end index:<br />
 <br />
Enter regex i.e. foo<br />
Enter “input string” for search i.e. foofoofoo<br />
Text foo is found that starts at index zero &amp; ends at index three.<br />
Text foo is found that starts at index three &amp; ends at index six.<br />
Text foo is found that starts at index six &amp; ends at index nine.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1282-string-literals.html</guid>
		</item>
		<item>
			<title>How Are Regular Expressions Represented?</title>
			<link>http://www.java-forums.org/blogs/java-string/1281-how-regular-expressions-represented.html</link>
			<pubDate>Thu, 26 Apr 2012 16:45:49 GMT</pubDate>
			<description>Package java.util.regex has three classes: PatternSyntaxException, Matcher and Pattern. 
 
 
* Pattern object is basically the compiled presentation...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Package java.util.regex has three classes: PatternSyntaxException, Matcher and Pattern.<br />
<br />
<ul><li style="">Pattern object is basically the compiled presentation of regular expression. For pattern creation first thing is invoking public static methods of compilation that will make pattern object to be returned. Regular expression is accepted by these methods being 1st argument; 1st trial lessons will let you know regarding the required syntax.</li><li style="">Matcher object is considered to be an engine which will be interpreting patterns. Also, match operations are being performed for input string. Matcher doesn’t define any public constructors. Matcher object is obtained when matcher method is invoked at pattern object.</li><li style="">PatternSyntaxException is basically unchecked kind of exception which shows sytax errors present in regular expression.</li></ul><br />
<br />
<br />
Few last trial lessons explore out all classes in detail. However, first of all one shall understand that how to construct the regular expressions. Hence simpler test harness will be introduced in next section which will repeatedly be used for their syntax exploring.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1281-how-regular-expressions-represented.html</guid>
		</item>
		<item>
			<title>Using Regular Expressions with String.matches()</title>
			<link>http://www.java-forums.org/blogs/java-string/1280-using-regular-expressions-string-matches.html</link>
			<pubDate>Thu, 26 Apr 2012 16:44:08 GMT</pubDate>
			<description>Built in support is provided by Strings present in Java for the regular expressions. There are 3 built in methods present in Strings for regular...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Built in support is provided by Strings present in Java for the regular expressions. There are 3 built in methods present in Strings for regular expressions. For example: replace(), split() and matches().<br />
<br />
There is no optimization of methods for performance. Classes will be used later on, which are performance optimized.<br />
<br />
<b>s.matches(&quot;regex&quot;)</b>: Evaluates if &quot;regex&quot; matches s. Returns only true if the WHOLE string can be matched<br />
<b>s.split(&quot;regex&quot;)</b>:C reates array with substrings of s divided at occurance of &quot;regex&quot;. &quot;regex&quot; is not included in the result.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1280-using-regular-expressions-string-matches.html</guid>
		</item>
		<item>
			<title>Regular Expressions Overview</title>
			<link>http://www.java-forums.org/blogs/java-string/1279-regular-expressions-overview.html</link>
			<pubDate>Thu, 26 Apr 2012 16:42:19 GMT</pubDate>
			<description>For strings, search pattern is defined by the regular expression. Such kind of pattern might be matching one time or several times, or not at all....</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">For strings, search pattern is defined by the regular expression. Such kind of pattern might be matching one time or several times, or not at all. Regular expression has an abbreviation “regex”.<br />
String (literal) is a simpler example of regular expression. E.g. Hello World string will be matched with Hello World regex.<br />
<br />
Other regular expression example is (dot) “.” That match with just one single character; and it will be matching e.g. “z”or ”a” or ”1”.<br />
<br />
<b>Usage</b><br />
<br />
Regular expressions could be used for editing, searching or text manipulation.<br />
Majority of the programming languages provide support to the regular expression.<br />
Unfortunately, a little different support is being provided by every language to the regular expression.<br />
If regular expression modifies or analyses the text, this is known as ‘Regular expression applicable to text’</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1279-regular-expressions-overview.html</guid>
		</item>
		<item>
			<title>Memory usage of StringBuilder and StringBuffer</title>
			<link>http://www.java-forums.org/blogs/java-string/1278-memory-usage-stringbuilder-stringbuffer.html</link>
			<pubDate>Thu, 26 Apr 2012 16:39:32 GMT</pubDate>
			<description><![CDATA[The implementation of these classes is essentially done in similar manner through the shared subclasses & usage of their memory is also same....]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">The implementation of these classes is essentially done in similar manner through the shared subclasses &amp; usage of their memory is also same. Difference comes when the turn of those methods come that are present at StringBuffer get synchronized. Here they will be referred as the string buffers generically for sake of simplicity however; comment at the usage of memory will be applied to both classes.<br />
<br />
Object’s overhead is required by the string buffer, space for sake of int field and also space for reference, to underlying char arrays. This results into 16 bytes and padding is not needed. Char array would be requiring 12 overhead bytes, and then 2 bytes are required per character capacity, which roundup to multiple of eight. Therefore when initializsation of buffer is done to sixteen then it would give 60 bytes, which are rounded as 64 bytes.<br />
<br />
It is important to note that when we call append(), the capacity of a string buffer doubles until it can hold the next character to be added. Thus, creating a default string buffer and then adding 17 characters will leave it with a capacity of 16*2=32 characters, each character position needing two bytes. and its memory usage will be 16+12+(32*2)=92, rounded up to 96 bytes.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1278-memory-usage-stringbuilder-stringbuffer.html</guid>
		</item>
		<item>
			<title>StringBuffer Functions</title>
			<link>http://www.java-forums.org/blogs/java-string/1277-stringbuffer-functions.html</link>
			<pubDate>Thu, 26 Apr 2012 16:38:36 GMT</pubDate>
			<description>Few StringBuffer methods has many uses which is being explained by the following program: 
 
*1. capacity()* 
String buffer’s current capacity is...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Few StringBuffer methods has many uses which is being explained by the following program:<br />
<br />
<b>1. capacity()</b><br />
String buffer’s current capacity is returned.<br />
<br />
<b>2. length()</b><br />
String buffer’s length is returned.<br />
<br />
<b>3. charAt(int index)</b><br />
Specified sequence character which is presented by string buffer are returned.<br />
<br />
<b>4. setCharAt(int index, char ch)</b><br />
At specified index, the character of this string buffer has been set to ch<br />
<br />
<b>5. toString()</b><br />
Gets converted to String presenting data which is there in string buffer.<br />
<br />
<b>6. insert(int offset, char c)</b><br />
String presentation is inserted, of char argument, to string buffer.<br />
<br />
<b>7. delete(int start, int end)</b><br />
characters which are present in a StringBuffer’s substring are removed.<br />
<br />
<b>8. replace(int start, int end, String str)</b><br />
Replaces those characters which are present in a StringBuffer’s substring, with characters which are there in the specified String.<br />
<br />
<b>9. reverse()</b><br />
In string buffer, character sequence is present which is replaced by sequence reverse.<br />
<br />
<b>10. append(String str)</b><br />
string is appended to this string buffer.<br />
<br />
<b>11. setLength(int newLength)</b><br />
Sets this String buffer’s length.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1277-stringbuffer-functions.html</guid>
		</item>
		<item>
			<title>StringBuffer</title>
			<link>http://www.java-forums.org/blogs/java-string/1276-stringbuffer.html</link>
			<pubDate>Thu, 26 Apr 2012 16:36:59 GMT</pubDate>
			<description><![CDATA[Thread safed & mutable character sequence. Basically it is just like String however modifications could be done with it. At any time, few specified...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Thread safed &amp; mutable character sequence. Basically it is just like String however modifications could be done with it. At any time, few specified character sequences are present in it but the content or length of that sequence might be changed via method calls.<br />
<br />
Mutilple threads may use string buffers safely. Synchronization of methods is done where it is considered to be an important thing hence all operations that take place at some specific instance would behave like they take place in a serial order which is quite consistent with the method calls order, made by individual threads.<br />
<br />
On a StringBuffer, operations append and methods are inserted that are overloaded to accept any type of data. A given datum is converted effectively into a string and then characters are inserted of that string, into string buffer. These characters are always added by the append method at the buffer’s end. Characters are added by the insert method at some specific point.<br />
<br />
Let’s say if z is being referred to the string buffer object. “Start” is its current content. String buffer will be caused by method call z.append(&quot;le&quot;) to have “starlet”. String Buffer will be altered by z.insert(4, &quot;le&quot;) to have “starlet”</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1276-stringbuffer.html</guid>
		</item>
		<item>
			<title>Understanding String memory usage</title>
			<link>http://www.java-forums.org/blogs/java-string/1275-understanding-string-memory-usage.html</link>
			<pubDate>Thu, 26 Apr 2012 16:36:07 GMT</pubDate>
			<description>Fields which are present at the String object shall be looked first of all so that for a better understanding of the above calculations: 
 
 
* a...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Fields which are present at the String object shall be looked first of all so that for a better understanding of the above calculations:<br />
<br />
<ul><li style="">a char array: Separate object which consist of the actual characters;</li><li style="">an integer offset where the string starts;</li><li style="">String Length</li><li style="">Another int, for hash code’s cached calculations. </li></ul><br />
<br />
<br />
This shows that if no characters are present in a string, even then 4 bytes would be required for sake of the char array reference along with 12 bytes for sake of 2 int fields plus object header’s 8 bytes. This will be providing 24 bytes that is basically multiple of 8 therefore padding bytes wouldn’t be needed. Char array (empty) will further needing 12 bytes along with 4 padding bytes so that memory could be brought to multiple of 16 that has been utilized by char array. Hence 40 bytes will be used by an empty string.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1275-understanding-string-memory-usage.html</guid>
		</item>
		<item>
			<title>Memory usage of Java Strings and string-related objects</title>
			<link>http://www.java-forums.org/blogs/java-string/1274-memory-usage-java-strings-string-related-objects.html</link>
			<pubDate>Thu, 26 Apr 2012 16:35:06 GMT</pubDate>
			<description>Everywhere strings are present. It is quite difficult thing to write down an application that is not used by them or others use it extensively....</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Everywhere strings are present. It is quite difficult thing to write down an application that is not used by them or others use it extensively. Various typical applications like server entities that are obtained from databases, or data present to be displayed at web, most of the objects that have been stored on heap might be Strings. Therefore, when usage of memory is crucial it means that understanding of the Strings memory usage or the related objects is also crucial.<br />
<br />
If your have command over using the C language or other and don’t know how to deal with Unicode then you might have an expectation that one byte per character be taken up essentially by a string plus one byte terminator. But for Java languages it doesn’t happen now days.<br />
<br />
<ul><li style="">Atleast eight bytes (of housekeeping data) of each object are present. Array of 12 bytes and they all will get padded to 16 bytes multiples.</li><li style="">Actually, Java String may have one or more than 1 object;</li><li style="">Few extra variables are present in a Java String that has not yet been considered. </li></ul></blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1274-memory-usage-java-strings-string-related-objects.html</guid>
		</item>
		<item>
			<title>Getting Characters and Substrings by Index</title>
			<link>http://www.java-forums.org/blogs/java-string/1273-getting-characters-substrings-index.html</link>
			<pubDate>Thu, 26 Apr 2012 16:34:00 GMT</pubDate>
			<description>Character can be obtained at one particular index, within a string, by charAt() accessor method’s invoking. First character index is 0 however last...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Character can be obtained at one particular index, within a string, by charAt() accessor method’s invoking. First character index is 0 however last character index is length()-1. This given example shows the code which obtains the character, at index 9 present in string.<br />
String anotherPalindrome = &quot;Niagara. O roar again!&quot;; <br />
<br />
char aChar = anotherPalindrome.charAt(9);<br />
<br />
Indices start with 0 therefore the characters which are present at the index 9 are 'O'. Here it is shown below. <br />
<div style="text-align: center;"><br />
<img src="http://www.java-forums.org/attachments/java-software/3643d1335458026-javaop-beta-42b-1.jpg" border="0" alt="Name:  1.jpg
Views: 31
Size:  7.5 KB" class="thumbnail" style="float:CONFIG" /><br />
<b>Getting Characters and Substrings by Index</b></div><br />
From a string obtain more then 1 characters which are also consecutive, by using substring method.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1273-getting-characters-substrings-index.html</guid>
		</item>
		<item>
			<title>Converting Strings to Numbers</title>
			<link>http://www.java-forums.org/blogs/java-string/1272-converting-strings-numbers.html</link>
			<pubDate>Thu, 26 Apr 2012 16:32:17 GMT</pubDate>
			<description>In a string object, usually a program would be ending up with numeric data, a value which user will enter. For example: 
Primitive numeric types...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">In a string object, usually a program would be ending up with numeric data, a value which user will enter. For example:<br />
Primitive numeric types (Short, Integer, Byte, Double, Long and Float) are being wrapped by the Number subclasses. A class method known as valueOf is provided by each which makes a string to be converted into object of that type. For example, ValueOfDemo will be getting 2 strings to convert them into no. and then performing the arithmetic operations at values.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">public class ValueOfDemo {
    public static void main(String&#91;&#93; args) {

        // this program requires two 
        // arguments on the command line 
        if (args.length == 2) {
            // convert strings to numbers
            float a = (Float.valueOf(args&#91;0&#93;)).floatValue(); 
            float b = (Float.valueOf(args&#91;1&#93;)).floatValue();

            // do some arithmetic
            System.out.println(&quot;a + b = &quot; +
                               (a + b));
            System.out.println(&quot;a - b = &quot; +
                               (a - b));
            System.out.println(&quot;a * b = &quot; +
                               (a * b));
            System.out.println(&quot;a / b = &quot; +
                               (a / b));
            System.out.println(&quot;a % b = &quot; +
                               (a % b));
        } else {
            System.out.println(&quot;This program &quot; +
                &quot;requires two command-line arguments.&quot;);
        }
    }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1272-converting-strings-numbers.html</guid>
		</item>
		<item>
			<title>The difference between == and equals()</title>
			<link>http://www.java-forums.org/blogs/java-string/1271-difference-between-equals.html</link>
			<pubDate>Thu, 26 Apr 2012 16:31:33 GMT</pubDate>
			<description>*The == operator:* 
References are compared by == operator, of the 2 objects which are present in memory.  When these 2 objects are pointing similar...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><b>The == operator:</b><br />
References are compared by == operator, of the 2 objects which are present in memory.  When these 2 objects are pointing similar memory location, then it returns true. It shall be remembered that in java strings are immutable therefore if string variables “str1” is present along with “abc” value and then another variable along with other value is created, instead of new string variable creation with same value, then Java simply would be pointing str2 to similar location of memory which has value of str1.<br />
In such a case,“str1==str2” returns true as both of str1 as well as str2 refer the similar object present in memory.<br />
<br />
<b>The equals() method:</b><br />
Text content and string variable’s value is compared by the equals method. Both of the variables having similar value, in that case, equal() method would be returning true, otherwise false. Hence str1.equals(str2) and str1.equals(str3) and str2.equals(str3), all would be returned true.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1271-difference-between-equals.html</guid>
		</item>
		<item>
			<title>String Conversion and toString() in Java</title>
			<link>http://www.java-forums.org/blogs/java-string/1270-string-conversion-tostring-java.html</link>
			<pubDate>Thu, 26 Apr 2012 16:30:38 GMT</pubDate>
			<description>When data is converted into string representation while concatenation is done, versions that are overloaded string conversion methods valueOf() are...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">When data is converted into string representation while concatenation is done, versions that are overloaded string conversion methods valueOf() are called. They are defined by the help of String.valueOf(), which are overloaded for type Object and all simpler types. In case of simple types, a string is returned by the valueOf() in which human readable are present that are equal to value that has been called. On the object, toString() method is called by ValueOf(). Here toString() method shall be examined as it will be determining the object’s string representation for the created classes.<br />
<br />
toString() is implemented by each class as object defines it. Tostring() default implementation is sufficient. Override toString() for those classes which are created to provide string representations of your own. This is easily done fortunately. General form of toString() method is as following:<br />
<br />
String toString( )</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1270-string-conversion-tostring-java.html</guid>
		</item>
		<item>
			<title>String Equality and Interning</title>
			<link>http://www.java-forums.org/blogs/java-string/1269-string-equality-interning.html</link>
			<pubDate>Thu, 26 Apr 2012 16:29:51 GMT</pubDate>
			<description>In Java Strings are the objects however they resemble primitives like charS or intS. In that java source, code may be having the String literals and...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">In Java Strings are the objects however they resemble primitives like charS or intS. In that java source, code may be having the String literals and + operator might be used to concatenate the Strings. These features are quite convenient, however similarity present b/w Strings &amp; primitives may cause certain confusions, when comparison is done of the Strings.<br />
<br />
Two mechanisms are provided by Java to do the test for equality. Use “==” operator for testing of the primitive values equality. It might also be used to find out whether 2 object references are being pointed at the similar underlying objects. The equal(Object) method return to be true for java objects when argument is equivalent to that object at which method gets invoked. This happened when class semantics of object are used to define the equality.<br />
<br />
Strings are the objects. To return the equals(Object) method true, two strings shall be having similar content which means similar characters shall be there in similar order. The == operator is considered to be true only when 2 string references will be pointing at similar, underlying String object. Therefore, same content is presented by 2 strings that would be equal when test is done by the equal(Object)method.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1269-string-equality-interning.html</guid>
		</item>
		<item>
			<title>Differences between String and StringBuffer in Java</title>
			<link>http://www.java-forums.org/blogs/java-string/1268-differences-between-string-stringbuffer-java.html</link>
			<pubDate>Thu, 26 Apr 2012 16:29:02 GMT</pubDate>
			<description>Major difference that exist b/w StringBuffer and String is the immutable string, while mutability of the StringBuffer means that StringBuffer object...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Major difference that exist b/w StringBuffer and String is the immutable string, while mutability of the StringBuffer means that StringBuffer object could be modified once it has been created, without creation of new object. StringBuffer is made an ideal choice by this mutable property to deal with Java strings. StringBuffer can be converted into String by the help of toString() method. StrinBuffer Vs String, or difference b/w String &amp; StringBuffer is most popular for the interview questions, either 1st round or phone interview. StringBuilder is also included now a days and StringBuiler Vs StringBuffer Vs String is asked. So you shall be prepared, for that. Difference b/w StringBuilder and StringBuffer will be shown in next section.</blockquote>

]]></content:encoded>
			<dc:creator>Java String</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-string/1268-differences-between-string-stringbuffer-java.html</guid>
		</item>
	</channel>
</rss>
