<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Computer FAQs &#38; Tips &#187; Programming</title>
	<atom:link href="http://www.computer-faqs.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.computer-faqs.com</link>
	<description>Answers to your Questions, Tips to enhance your Experience</description>
	<lastBuildDate>Sun, 16 Aug 2009 23:16:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Java: How to convert String to array?</title>
		<link>http://www.computer-faqs.com/2009/02/11/java-how-to-convert-string-to-array/</link>
		<comments>http://www.computer-faqs.com/2009/02/11/java-how-to-convert-string-to-array/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 04:39:13 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.computer-faqs.com/?p=613</guid>
		<description><![CDATA[Sometime you get a string in a fixed format and you want individualise it and store them into array so you can manipulate it easier with your other functions. For example, String array = &#34;one,two,three,four,five,six,seven,eight,nine&#34;; will become String&#91;&#93; words = &#123;one,two,three,four,five,six,seven,eight,nine&#125;; Below code is demonstrating how fixed format string can be broken down and stored [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime you get a string in a fixed format and you want individualise it and store them into array so you can manipulate it easier with your other functions.</p>
<p>For example,</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span> array <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;one,two,three,four,five,six,seven,eight,nine&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>will become</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> words <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>one,two,three,four,five,six,seven,eight,nine<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Below code is demonstrating how fixed format string can be broken down and stored into array.</p>
<p><strong>Class: <code>StringToArray.java</code></strong><br />
<span id="more-613"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Computer-FAQS.com
 * @author Manet Yim (manet.yim at gmail dot com)
 * @license: GPL v3.0
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> StringToArray <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Testing method
     * @param args
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// your raw string in a fixed format</span>
        <span style="color: #003399;">String</span> array <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;one,two,three,four,five,six,seven,eight,nine&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// converting raw string input array object and display it</span>
        <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> convertedArray <span style="color: #339933;">=</span> StringToArray.<span style="color: #006633;">convert</span><span style="color: #009900;">&#40;</span>array, <span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>convertedArray.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>convertedArray<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Convert a String s to an Array, where each element in string 
     * seperated by sep
     * 
     * @param str String to be converted
     * @param sep Element seperator
     * @return Array of strings
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> convert<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> str, <span style="color: #003399;">String</span> sep<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">StringBuffer</span> sBuf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// there is at least one element in the array</span>
        <span style="color: #000066; font-weight: bold;">int</span> aSize <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Counting how many separator in the string</span>
        <span style="color: #666666; font-style: italic;">// result will be the size of new array</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> sBuf.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sep.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>sBuf.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
                aSize<span style="color: #339933;">++;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// create new array object with predefined size</span>
        <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> elements <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span>aSize<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">int</span> x, y <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sBuf.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>sep<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>sBuf.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sBuf.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>sep<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    x <span style="color: #339933;">=</span> sBuf.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>sep<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>x <span style="color: #339933;">!=</span> sBuf.<span style="color: #006633;">lastIndexOf</span><span style="color: #009900;">&#40;</span>sep<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        elements<span style="color: #009900;">&#91;</span>y<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> sBuf.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, x<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        y<span style="color: #339933;">++;</span>
                        sBuf.<span style="color: #006633;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, x <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sBuf.<span style="color: #006633;">lastIndexOf</span><span style="color: #009900;">&#40;</span>sep<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> x<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        elements<span style="color: #009900;">&#91;</span>y<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> sBuf.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, sBuf.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>sep<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        y<span style="color: #339933;">++;</span>
                        sBuf.<span style="color: #006633;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, sBuf.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>sep<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        elements<span style="color: #009900;">&#91;</span>y<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> sBuf.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        y<span style="color: #339933;">++;</span>
                        sBuf.<span style="color: #006633;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, sBuf.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            elements<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> sBuf.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        sBuf <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> elements<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2009/02/11/java-how-to-convert-string-to-array/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to copy text file in Java?</title>
		<link>http://www.computer-faqs.com/2009/01/30/how-to-copy-text-file-in-java/</link>
		<comments>http://www.computer-faqs.com/2009/01/30/how-to-copy-text-file-in-java/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 01:09:19 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java-FileReader]]></category>
		<category><![CDATA[Java-FileWriter]]></category>

		<guid isPermaLink="false">http://www.computer-faqs.com/?p=611</guid>
		<description><![CDATA[Code below demonstrating how to copy data from one text file to another in Java. This testing method, is calling FileCopier.copyFile(File, File) to copy content of file test1.css to file test2.css public static void main&#40;String&#91;&#93; args&#41; &#123; FileCopier.copyFile&#40;new File&#40;&#34;D:/TEMP/test1.css&#34;&#41;, new File&#40;&#34;D:/TEMP/test2.css&#34;&#41;&#41;; &#125; Class: FileCopier.java import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Code below demonstrating how to copy data from one text file to another in Java.</p>
<p>This testing method, is calling <code>FileCopier.copyFile(File, File)</code> to copy content of file <code>test1.css</code> to file <code>test2.css</code></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        FileCopier.<span style="color: #006633;">copyFile</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D:/TEMP/test1.css&quot;</span><span style="color: #009900;">&#41;</span>, 
                            <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D:/TEMP/test2.css&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Class: <code>FileCopier.java</code></strong><br />
<span id="more-611"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileNotFoundException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileWriter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FileCopier <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Testing Method
     * @param args
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        FileCopier.<span style="color: #006633;">copyFile</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D:/TEMP/test1.css&quot;</span><span style="color: #009900;">&#41;</span>, 
                            <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D:/TEMP/test2.css&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Copy content of file f1 into file f2
     * @param f1
     * @param f2
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> copyFile<span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span> f1, <span style="color: #003399;">File</span> f2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">FileReader</span> in <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileReader</span><span style="color: #009900;">&#40;</span>f1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">FileWriter</span> out <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileWriter</span><span style="color: #009900;">&#40;</span>f2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> line<span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">=</span> in.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// Read line fromtext file and write to destination file</span>
                out.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>line<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            in.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            out.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">FileNotFoundException</span> ffx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            ffx.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> iox<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            iox.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2009/01/30/how-to-copy-text-file-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understand Java break and continue Statements</title>
		<link>http://www.computer-faqs.com/2009/01/19/understand-java-break-and-continue-statements/</link>
		<comments>http://www.computer-faqs.com/2009/01/19/understand-java-break-and-continue-statements/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 00:14:57 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java-Statement]]></category>

		<guid isPermaLink="false">http://www.computer-faqs.com/?p=560</guid>
		<description><![CDATA[Let&#8217;s get it right and understand on usage of break and continue Statements in Java Programming Language. break Statement This statement causes iteration to stop/exit immediately, any line remained after this statement will be ignored by the JVM. It is used in the following loop for while do&#8230;while switch continue Statement This statement skips the [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s get it right and understand on usage of break and continue Statements in Java Programming Language.</p>
<h4><code>break</code> Statement</h4>
<p>This statement causes iteration to stop/exit immediately, any line remained after this statement will be ignored by the JVM.</p>
<p>It is used in the following loop</p>
<ul>
<li>for</li>
<li>while</li>
<li>do&#8230;while</li>
<li>switch</li>
</ul>
<h4><code>continue</code> Statement</h4>
<p>This statement skips the current iteration of the loop, any line after this statement will not be executed by the JVM until the condition is met.<br />
<span id="more-560"></span><br />
It is used in the following loop</p>
<ul>
<li>for</li>
<li>while</li>
<li>do&#8230;while</li>
</ul>
<p>Example code below demonstrating how break and continue statement work</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BreakContinueStm <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">int</span> aBreak <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> bContinue <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">==</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// that's enough, exit this for loop here</span>
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            aBreak <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;aBreak: &quot;</span> <span style="color: #339933;">+</span> aBreak<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// not satisfied yet, keep going</span>
                <span style="color: #000000; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            bContinue <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;bContinue: &quot;</span> <span style="color: #339933;">+</span> bContinue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Result of this program, <code>aBreak</code> stops when <code>i = 6</code> and <code>bContinue</code> starts when <code>i = 6</code> until end of the loop</p>
<pre class="cmdterminal">
aBreak: 1
aBreak: 2
aBreak: 3
aBreak: 4
aBreak: 5
bContinue: 6
bContinue: 7
bContinue: 8
bContinue: 9
bContinue: 10
</pre>
<div class="admedia">
AD » Recommended Java book <a href="http://www.amazon.com/gp/product/0132222205?ie=UTF8&amp;tag=cofa-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0132222205">Java How to Program, 7th Edition</a> ( by Harvey M. Deitel, Paul J. Deitel )</div>
]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2009/01/19/understand-java-break-and-continue-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add or display favicon on a webpage?</title>
		<link>http://www.computer-faqs.com/2009/01/17/how-to-add-display-favicon-on-a-webpage/</link>
		<comments>http://www.computer-faqs.com/2009/01/17/how-to-add-display-favicon-on-a-webpage/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 00:09:49 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[favicon]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://www.computer-faqs.com/?p=641</guid>
		<description><![CDATA[What is favicon? Favicon is shortcut of favorites icon, also known as website icon, shortcut icon, url icon, or bookmark icon. On the graphical web browser, this icon locates on the Address bar and Tabs bar as seen in the screenshot below. Add favicon You required to have an image of 16&#215;16 pixels, either PNG, [...]]]></description>
			<content:encoded><![CDATA[<h4>What is favicon?</h4>
<p><strong>Favicon</strong> is shortcut of favorites icon, also known as website icon, shortcut icon, url icon, or bookmark icon.</p>
<p>On the graphical web browser, this icon locates on the Address bar and Tabs bar as seen in the screenshot below.</p>
<div id="attachment_643" class="wp-caption alignnone" style="width: 310px"><a href="http://www.computer-faqs.com/wp-content/uploads/2009/01/screenshot-favicon-demo.png" rel="lightbox[641]"><img class="size-medium wp-image-643" title="screenshot-favicon-demo" src="http://www.computer-faqs.com/wp-content/uploads/2009/01/screenshot-favicon-demo-300x82.png" alt="Screenshot of favicon" width="300" height="82" /></a><p class="wp-caption-text">Screenshot of favicon</p></div>
<h4>Add favicon</h4>
<p>You required to have an image of <strong><em>16&#215;16</em></strong> pixels, either <strong><em>PNG, ICO </em></strong>or<strong><em> GIF</em></strong> format</p>
<p>To display favicon to your webpage, add <strong>one</strong> of the following html code inside <code>&lt;head&gt;</code> depends on which image format you have.</p>
<blockquote class="codehtml"><p>&lt;head&gt;<br />
&lt;link rel=&#8221;icon&#8221; type=&#8221;image/x-icon&#8221; href=&#8221;path/myicon.ico&#8221;&gt;<br />
&lt;/head&gt;</p></blockquote>
<blockquote class="codehtml"><p>&lt;head&gt;<br />
&lt;link rel=&#8221;icon&#8221; type=&#8221;image/png&#8221; href=&#8221;path/myicon.png&#8221;&gt;<br />
&lt;/head&gt;</p></blockquote>
<blockquote class="codehtml"><p>&lt;head&gt;<br />
&lt;link rel=&#8221;icon&#8221; type=&#8221;image/gif&#8221; href=&#8221;path/myicon.gif&#8221;&gt;<br />
&lt;/head&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2009/01/17/how-to-add-display-favicon-on-a-webpage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate Random Password in Java</title>
		<link>http://www.computer-faqs.com/2009/01/16/generate-random-password-in-java/</link>
		<comments>http://www.computer-faqs.com/2009/01/16/generate-random-password-in-java/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 11:49:33 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java-Random]]></category>

		<guid isPermaLink="false">http://www.computer-faqs.com/?p=599</guid>
		<description><![CDATA[This article demonstrates how to generate random password or string using java.util.Random. You can define your own set of characters in this string variable private static final String charset = &#34;!0123456789abcdefghijklmnopqrstuvwxyz&#34;; Class: RandomPassword.java import java.util.Random; &#160; public class RandomPassword &#123; &#160; private static final String charset = &#34;!0123456789abcdefghijklmnopqrstuvwxyz&#34;; &#160; public static String getRandomString&#40;int length&#41; &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>This article demonstrates how to generate random password or string using <code>java.util.Random</code>.</p>
<p>You can define your own set of characters in this string variable</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> charset <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;!0123456789abcdefghijklmnopqrstuvwxyz&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Class: <code>RandomPassword.java</code></strong><br />
<span id="more-599"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Random</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RandomPassword <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> charset <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;!0123456789abcdefghijklmnopqrstuvwxyz&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> getRandomString<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> length<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">Random</span> rand <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Random</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">StringBuffer</span> sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> length<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">int</span> pos <span style="color: #339933;">=</span> rand.<span style="color: #006633;">nextInt</span><span style="color: #009900;">&#40;</span>charset.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>charset.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>pos<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>RandomString.<span style="color: #006633;">getRandomString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// if you generate more than 1 time, you must</span>
                <span style="color: #666666; font-style: italic;">// put the process to sleep for awhile</span>
                <span style="color: #666666; font-style: italic;">// otherwise it will return the same random string</span>
                <span style="color: #003399;">Thread</span>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">InterruptedException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Below is the output of this program. It genereates 10 passwords with 10 random character in each password</p>
<pre class="cmdterminal">
2b!2!9dc42
1b46d!b690
a536c16b69
8adb1577db
7a4!!ac14a
c!!da703b4
85550483!a
8a!4!53bc4
94282b229b
5a1080a2b1
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2009/01/16/generate-random-password-in-java/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Use Calendar instead of Date in Java</title>
		<link>http://www.computer-faqs.com/2009/01/14/use-calendar-instead-of-date-in-java/</link>
		<comments>http://www.computer-faqs.com/2009/01/14/use-calendar-instead-of-date-in-java/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 00:03:14 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java-Calendar]]></category>
		<category><![CDATA[Java-SimpleDateFormat]]></category>

		<guid isPermaLink="false">http://www.computer-faqs.com/?p=589</guid>
		<description><![CDATA[Common Issue When you use java.util.Date object with JDK version higher than 1.1 Date d = new Date&#40;&#41;; d.getMonth&#40;&#41;; You will get deprecated warning messages when you try to compile The method getMonth() from the type Date is deprecated However you can supress the warning message by adding @SuppressWarnings("deprecation") to you main() method @SuppressWarnings&#40;&#34;deprecation&#34;&#41; public [...]]]></description>
			<content:encoded><![CDATA[<h4>Common Issue</h4>
<p>When you use <code>java.util.Date</code> object with JDK version higher than 1.1</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Date</span> d <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
d.<span style="color: #006633;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You will get deprecated warning messages when you try to compile</p>
<pre class="cmdterminal">
The method getMonth() from the type Date is deprecated
</pre>
<p>However you can supress the warning message by adding <code>@SuppressWarnings("deprecation")</code> to you <code>main()</code> method</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;deprecation&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    ...
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>or adding <code>@SuppressWarnings("unchecked")</code> to other method</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unchecked&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> otherMethod<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    ...
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Note</strong> that this can only be used in JDK 5.0+</p>
<h4>Alternative</h4>
<p>Now let&#8217;s forget about working around the deprecated method, let&#8217;s learn how to use <code>java.util.Calendar</code> instead<br />
<span id="more-589"></span><br />
Example code below is showing you how to use Calendar object and format the date in the way you required.</p>
<p><strong>Class: <code>TestCalendar.java</code></strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.SimpleDateFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Calendar</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestCalendar <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">Calendar</span> current <span style="color: #339933;">=</span> <span style="color: #003399;">Calendar</span>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">Calendar</span> last6month <span style="color: #339933;">=</span> <span style="color: #003399;">Calendar</span>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        last6month.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span>.<span style="color: #006633;">MONTH</span>, current.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span>.<span style="color: #006633;">MONTH</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">SimpleDateFormat</span> dformatter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">SimpleDateFormat</span><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">&quot;dd/MM/yyyy HH:MM:SS a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Calendar Object: &quot;</span> <span style="color: #339933;">+</span> current<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Default Date: &quot;</span> <span style="color: #339933;">+</span> current.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;User Formatted Date: &quot;</span>
                <span style="color: #339933;">+</span> dformatter.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>current.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Output of this program</p>
<pre class="cmdterminal">
Calendar Object: java.util.GregorianCalendar[time=1231889016972,
  areFieldsSet=true,areAllFieldsSet=true,lenient=true,
  zone=sun.util.calendar.ZoneInfo[id="Australia/Sydney",offset=36000000,
  dstSavings=3600000,useDaylight=true,transitions=142,
  lastRule=java.util.SimpleTimeZone[id=Australia/Sydney,offset=36000000,
  dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=9,
  startDay=-1,startDayOfWeek=1,startTime=7200000,startTimeMode=1,endMode=2,
  endMonth=2,endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=1]],
  firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2009,MONTH=0,
  WEEK_OF_YEAR=3,WEEK_OF_MONTH=3 DAY_OF_MONTH=14,DAY_OF_YEAR=14,
  DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=2,AM_PM=0,HOUR=10,HOUR_OF_DAY=10,
  MINUTE=23,SECOND=36,MILLISECOND=972,ZONE_OFFSET=36000000,
  DST_OFFSET=3600000]
Default Date: Wed Jan 14 10:23:36 EST 2009
User Formatted Date: 14/01/2009 10:01:972 AM
</pre>
<div class="admedia">
Advertisement » Recommended Java book <a href="http://www.amazon.com/gp/product/0132222205?ie=UTF8&amp;tag=cofa-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0132222205">Java How to Program, 7th Edition</a> ( by Harvey M. Deitel, Paul J. Deitel )</div>
]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2009/01/14/use-calendar-instead-of-date-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What are Java Operators?</title>
		<link>http://www.computer-faqs.com/2009/01/12/what-are-java-operators/</link>
		<comments>http://www.computer-faqs.com/2009/01/12/what-are-java-operators/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 13:02:21 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java-Operator]]></category>

		<guid isPermaLink="false">http://www.computer-faqs.com/?p=539</guid>
		<description><![CDATA[In Java Language, there are 4 types of operators Arithmetic Relational Logical Bitwise The rest of this post includes a small class to demonstrate on how those operators are used. Arithmetic Operators +  : Addition -  : Subtraction *  : Multiplication /  : Division %  : Modulus ++ : Increment -− : Decrement Example public [...]]]></description>
			<content:encoded><![CDATA[<p>In Java Language, there are 4 types of operators</p>
<ol>
<li>Arithmetic</li>
<li>Relational</li>
<li>Logical</li>
<li>Bitwise</li>
</ol>
<p>The rest of this post includes a small class to demonstrate on how those operators are used.</p>
<h4>Arithmetic Operators</h4>
<blockquote class="codefunction"><p>+  : Addition</p>
<p>-  : Subtraction</p>
<p>*  : Multiplication</p>
<p>/  : Division</p>
<p>%  : Modulus</p>
<p>++ : Increment</p>
<p>-− : Decrement</p></blockquote>
<p><span id="more-539"></span></p>
<p>Example</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ArithmeticOperator <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> a <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> b <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> ab <span style="color: #339933;">=</span> a <span style="color: #339933;">+</span> b<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> c <span style="color: #339933;">=</span> b <span style="color: #339933;">-</span> a<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> d <span style="color: #339933;">=</span> a <span style="color: #339933;">*</span> b<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> e <span style="color: #339933;">=</span> b<span style="color: #339933;">/</span>a<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> f <span style="color: #339933;">=</span> b<span style="color: #339933;">%</span>a<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> g <span style="color: #339933;">=</span> a<span style="color: #339933;">++;</span>
        <span style="color: #000066; font-weight: bold;">int</span> h <span style="color: #339933;">=</span> a<span style="color: #339933;">++;</span>
        <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #339933;">++</span>g<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #339933;">++</span>g<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> k <span style="color: #339933;">=</span> b<span style="color: #339933;">--;</span>
        <span style="color: #000066; font-weight: bold;">int</span> l <span style="color: #339933;">=</span> b<span style="color: #339933;">--;</span>
        <span style="color: #000066; font-weight: bold;">int</span> m <span style="color: #339933;">=</span> <span style="color: #339933;">--</span>l<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> n <span style="color: #339933;">=</span> <span style="color: #339933;">--</span>l<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">String</span> s <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;ab = &quot;</span> <span style="color: #339933;">+</span> ab <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;a  = &quot;</span> <span style="color: #339933;">+</span> a <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;b  = &quot;</span> <span style="color: #339933;">+</span> b <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;c  = &quot;</span> <span style="color: #339933;">+</span> c <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;d  = &quot;</span> <span style="color: #339933;">+</span> d <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;e  = &quot;</span> <span style="color: #339933;">+</span> e <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;f  = &quot;</span> <span style="color: #339933;">+</span> f <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;g  = &quot;</span> <span style="color: #339933;">+</span> g <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;h  = &quot;</span> <span style="color: #339933;">+</span> h <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;i  = &quot;</span> <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;j  = &quot;</span> <span style="color: #339933;">+</span> j <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;k  = &quot;</span> <span style="color: #339933;">+</span> k <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;l  = &quot;</span> <span style="color: #339933;">+</span> l <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;m  = &quot;</span> <span style="color: #339933;">+</span> m <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span> <span style="color: #339933;">+</span>
            <span style="color: #0000ff;">&quot;n  = &quot;</span> <span style="color: #339933;">+</span> n <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h4>Relational Operators</h4>
<blockquote class="codefunction"><p>== : Equal to</p>
<p>!= : Not equal to</p>
<p>&lt;  : Less than</p>
<p>&gt;  : Greater than</p>
<p>&lt;= : Less than or equal to</p>
<p>&gt;= : Greater than or equal to</p></blockquote>
<p>Example</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RelationalOperator <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">int</span> a <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> b <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a == b : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">==</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a != b : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">!=</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a &lt; b  : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">&lt;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a &gt; b  : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">&gt;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a &lt;= b : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">&lt;=</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a &gt;= b : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">&gt;=</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h4>Logical Operators</h4>
<blockquote class="codefunction"><p>&amp;  : Boolean AND</p>
<p>|  : Boolean OR</p>
<p>!  : Logical NOT</p>
<p>^  : Boolean XOR</p>
<p>|| : Logical OR</p>
<p>&amp;&amp; : Logical AND</p></blockquote>
<p>Example</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LogicalOperator <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">boolean</span> t <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">boolean</span> f <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;t &amp; f  : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>t <span style="color: #339933;">&amp;</span> f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;t | f  : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>t <span style="color: #339933;">|</span> f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;! f    : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;t ^ f  : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>t <span style="color: #339933;">^</span> f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;t || f : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>t <span style="color: #339933;">||</span> f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;t &amp;&amp; f : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>t <span style="color: #339933;">&amp;&amp;</span> f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h4>Bitwise Operators</h4>
<blockquote class="codefunction"><p>&amp;  : Boolean AND</p>
<p>|  : Boolean OR</p>
<p>~  : Boolean NOT</p>
<p>^  : Boolean XOR</p>
<p>&gt;&gt; : Shift Right</p>
<p>&lt;&lt; : Shift Left</p>
<p>&gt;&gt;&gt; : Shift Right Unsigned</p></blockquote>
<p>Example</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BitwiseOperator <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">int</span> a <span style="color: #339933;">=</span> <span style="color: #cc66cc;">123</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 1 1 1 1 0 1 1</span>
        <span style="color: #000066; font-weight: bold;">int</span> b <span style="color: #339933;">=</span> <span style="color: #cc66cc;">321</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 1 0 1 0 0 0 0 0 1</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a &amp; b   : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">&amp;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a | b   : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">|</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;~a      : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>~ a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a ^ b   : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">^</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a &gt;&gt; b  : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">&gt;&gt;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a &lt;&lt; b  : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">&lt;&lt;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a &gt;&gt;&gt; b : &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">&gt;&gt;&gt;</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<div class="media-download">
<h5>Source code</h5>
<p><a href='http://www.computer-faqs.com/wp-content/uploads/2009/01/operator-demo.zip'>operator-demo.zip</a></div>
<div class="admedia">
Advertisement » Recommended Java book <a href="http://www.amazon.com/gp/product/0132222205?ie=UTF8&amp;tag=cofa-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0132222205">Java How to Program, 7th Edition</a> ( by Harvey M. Deitel, Paul J. Deitel )</div>
]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2009/01/12/what-are-java-operators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to include CSS Style Sheet file in HTML Document?</title>
		<link>http://www.computer-faqs.com/2008/12/27/how-to-include-css-style-sheet-file-in-html-document/</link>
		<comments>http://www.computer-faqs.com/2008/12/27/how-to-include-css-style-sheet-file-in-html-document/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 00:30:17 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.computer-faqs.com/?p=64</guid>
		<description><![CDATA[Here is a quick tip. Code below showing you how to include CSS Style Sheet file in to HTML document &#60;html&#62; &#60;head&#62; &#60;title&#62;Page Title&#60;/title&#62; &#60;link type=&#8221;text/css&#8221; rel=&#8221;stylesheet&#8221; href=&#8221;path_to/styles.css&#8221; /&#62; &#60;/head&#62; &#60;body&#62; &#60;/body&#62; &#60;/html&#62;]]></description>
			<content:encoded><![CDATA[<p>Here is a quick tip. Code below showing you how to include CSS Style Sheet file in to HTML document</p>
<blockquote class="codehtml"><p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Page Title&lt;/title&gt;<br />
<strong>&lt;link type=&#8221;text/css&#8221; rel=&#8221;stylesheet&#8221; href=&#8221;path_to/styles.css&#8221; /&gt;</strong><br />
&lt;/head&gt; &lt;body&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2008/12/27/how-to-include-css-style-sheet-file-in-html-document/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to convert String to Date in SQL statement?</title>
		<link>http://www.computer-faqs.com/2008/12/24/how-to-convert-string-to-date-in-sql-statement/</link>
		<comments>http://www.computer-faqs.com/2008/12/24/how-to-convert-string-to-date-in-sql-statement/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 11:17:17 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Date-Conversion]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[Informix]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL-Function]]></category>

		<guid isPermaLink="false">http://www.computer-faqs.com/?p=58</guid>
		<description><![CDATA[This is a list of handy tips that could help you in a blink on how to convert String to Date in SQL. This post cover 5 popular databases (Oracle, MySQL, DB2, PostgreSQL, Informix) Post your comment here if you find this post useful or want to contribute more explaination. Oracle Syntax: to_date(date_string, format) Example: [...]]]></description>
			<content:encoded><![CDATA[<p>This is a list of handy tips that could help you in a blink on how to convert String to Date in SQL. This post cover 5 popular databases (Oracle, MySQL, DB2, PostgreSQL, Informix)</p>
<p>Post your comment here if you find this post useful or want to contribute more explaination.</p>
<h4>Oracle</h4>
<p>Syntax:</p>
<blockquote class="codefunction"><p>to_date(date_string, format)<strong><br />
</strong></p></blockquote>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> user<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> user<span style="color: #66cc66;">.</span>location <span style="color: #993333; font-weight: bold;">FROM</span> user
<span style="color: #993333; font-weight: bold;">WHERE</span> user<span style="color: #66cc66;">.</span>starteddtm <span style="color: #66cc66;">=</span> to_date<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'20/10/2007 16:01'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'dd/mm/yyyy hh24:mi'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p><span id="more-58"></span>(<a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions183.htm">more details</a> on this function)</p>
<h4>MySQL</h4>
<p>Syntax:</p>
<blockquote class="codefunction"><p>STR_TO_DATE(date_string, format)</p></blockquote>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> user<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> user<span style="color: #66cc66;">.</span>location <span style="color: #993333; font-weight: bold;">FROM</span> user
<span style="color: #993333; font-weight: bold;">WHERE</span> user<span style="color: #66cc66;">.</span>starteddtm <span style="color: #66cc66;">=</span> STR_TO_DATE<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'20/10/2007 16:01'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'%d/%m/%Y %H:%i'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>(see <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format">more details</a> on date format)</p>
<p><!-- http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date --></p>
<h4>DB2</h4>
<p>In DB2 You can use the following function to convert a character string to a date or time value</p>
<p>Syntax:</p>
<blockquote class="codefunction"><p>TIMESTAMP(date_time_string)<br />
DATE(date_string)<br />
TIME(time_string)</p></blockquote>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">TIMESTAMP <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'2002-10-20-12.00.00.000000'</span><span style="color: #66cc66;">&#41;</span>
TIMESTAMP <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'2002-10-20 12:00:00'</span><span style="color: #66cc66;">&#41;</span>
DATE <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'2002-10-20'</span><span style="color: #66cc66;">&#41;</span>
DATE <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'10/20/2002'</span><span style="color: #66cc66;">&#41;</span>
TIME <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'12:00:00'</span><span style="color: #66cc66;">&#41;</span>
TIME <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'12.00.00'</span><span style="color: #66cc66;">&#41;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> user<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> user<span style="color: #66cc66;">.</span>location <span style="color: #993333; font-weight: bold;">FROM</span> user
<span style="color: #993333; font-weight: bold;">WHERE</span> user<span style="color: #66cc66;">.</span>starteddtm <span style="color: #66cc66;">=</span> DATE<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'20/10/2007'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>(<a href="http://www.ibm.com/developerworks/db2/library/techarticle/0211yip/0211yip3.html">more details</a>)</p>
<h4>PostgreSQL</h4>
<p>Syntax:</p>
<blockquote class="codefunction"><p>to_date(date_string, format)</p></blockquote>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> user<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> user<span style="color: #66cc66;">.</span>location <span style="color: #993333; font-weight: bold;">FROM</span> user
<span style="color: #993333; font-weight: bold;">WHERE</span> user<span style="color: #66cc66;">.</span>starteddtm <span style="color: #66cc66;">=</span> STR_TO_DATE<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'20/10/2007 16:01'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'DD/MM/YYYY HH24:MI'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>(<a href="http://www.postgresql.org/docs/8.1/static/functions-formatting.html">more details</a>)</p>
<h4>Informix</h4>
<p>Syntax:</p>
<blockquote class="codefunction"><p>DATE(date_string)<br />
TO_DATE(date_string, format)</p></blockquote>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> user<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> user<span style="color: #66cc66;">.</span>location <span style="color: #993333; font-weight: bold;">FROM</span> user
<span style="color: #993333; font-weight: bold;">WHERE</span> user<span style="color: #66cc66;">.</span>starteddtm <span style="color: #66cc66;">=</span> DATE<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'20/10/2007'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> user<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> user<span style="color: #66cc66;">.</span>location <span style="color: #993333; font-weight: bold;">FROM</span> user
<span style="color: #993333; font-weight: bold;">WHERE</span> user<span style="color: #66cc66;">.</span>starteddtm <span style="color: #66cc66;">=</span> TO_DATE<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'20/10/2007 16:00'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'%d/%m/%Y %H:%M'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>(<a href="http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqlt.doc/sqltmst89.htm">more detail</a> on these functions)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2008/12/24/how-to-convert-string-to-date-in-sql-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to do Find and Replace in VBA?</title>
		<link>http://www.computer-faqs.com/2008/12/24/how-to-do-find-and-replace-in-vba/</link>
		<comments>http://www.computer-faqs.com/2008/12/24/how-to-do-find-and-replace-in-vba/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 02:24:16 +0000</pubDate>
		<dc:creator>Manet</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[MS-Office]]></category>
		<category><![CDATA[MS-Office-Word]]></category>
		<category><![CDATA[VB-VBA]]></category>

		<guid isPermaLink="false">http://www.computer-faqs.com/?p=84</guid>
		<description><![CDATA[If you want to automate your find and replace in MS Office Word Document You could use or modify this Sub to suit your own needs. Remember it only support upto 512 bytes (512 characters) of text at the time. Sub FindReplace() ' Find and replace string in document ' Support up to 512 bytes [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to automate your find and replace in MS Office Word Document<br />
You could use or modify this Sub to suit your own needs.</p>
<p>Remember it only support upto 512 bytes (512 characters) of text at the time.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> FindReplace()
<span style="color: #008000;">' Find and replace string in document
</span><span style="color: #008000;">' Support up to 512 bytes (double size the default)
</span>  <span style="color: #000080;">With</span> Selection.Find
    .ClearFormatting
    .Text = <span style="color: #800000;">&quot;old text&quot;</span>
    .Replacement.ClearFormatting
    .Replacement.Text = <span style="color: #800000;">&quot;new text&quot;</span>
    .Execute Replace:=wdReplaceAll, Forward:=<span style="color: #000080;">True</span>, Wrap:=wdFindContinue
  <span style="color: #000080;">End</span> <span style="color: #000080;">With</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.computer-faqs.com/2008/12/24/how-to-do-find-and-replace-in-vba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
