<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5316342384202108452</id><updated>2026-05-03T01:24:43.507-07:00</updated><title type='text'>Learn Java: Complete Java/J2EE Tutorial, Spring Framework, hibernet, jsp,</title><subtitle type='html'>java complete tutorial, core java, class method, spring, strut, hibernet,j-unit testing, j-script</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-4283779869694316536</id><published>2011-01-15T14:29:00.001-08:00</published><updated>2011-01-15T14:29:18.717-08:00</updated><title type='text'>Core Java:Branching statement</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
&lt;h1&gt;
Branching Statements&lt;/h1&gt;
&lt;/div&gt;
&lt;blockquote&gt;

&lt;h3&gt;
The &lt;code&gt;break&lt;/code&gt; Statement&lt;/h3&gt;
The &lt;code&gt;break&lt;/code&gt; statement has two forms: labeled and unlabeled. 
You saw the unlabeled form in the previous discussion of the &lt;code&gt;switch&lt;/code&gt; statement.
 
You can also use an unlabeled &lt;code&gt;break&lt;/code&gt; to terminate a &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, 
or &lt;code&gt;do-while&lt;/code&gt; loop, as shown in the following

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/BreakDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;BreakDemo&lt;/code&gt;&lt;/a&gt;
program: 

&lt;blockquote&gt;
&lt;pre&gt;class BreakDemo {
    public static void main(String[] args) {

        int[] arrayOfInts = { 32, 87, 3, 589, 12, 1076,
                              2000, 8, 622, 127 };
        int searchfor = 12;

        int i;
        boolean foundIt = false;

        for (i = 0; i &amp;lt; arrayOfInts.length; i++) {
            if (arrayOfInts[i] == searchfor) {
                foundIt = true;
                &lt;strong&gt;break;&lt;/strong&gt;
            }
        }

        if (foundIt) {
            System.out.println(&quot;Found &quot; + searchfor
                               + &quot; at index &quot; + i);
        } else {
            System.out.println(searchfor
                               + &quot; not in the array&quot;);
        }
    }
}&lt;/pre&gt;
&lt;/blockquote&gt;
This program searches for the number 12 in an array. The &lt;code&gt;break&lt;/code&gt; statement, shown in boldface, terminates the &lt;code&gt;for&lt;/code&gt; 
loop when that value is found. Control flow then transfers to 
the print statement at the end of the program.

This program&#39;s output is:
&lt;blockquote&gt;
&lt;pre&gt;Found 12 at index 4&lt;/pre&gt;
&lt;/blockquote&gt;
An unlabeled &lt;code&gt;break&lt;/code&gt; statement terminates the innermost 
&lt;code&gt;switch&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, or 
&lt;code&gt;do-while&lt;/code&gt; statement, but a labeled &lt;code&gt;break&lt;/code&gt; terminates an outer statement. 
The following program, 


&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/BreakWithLabelDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;BreakWithLabelDemo&lt;/code&gt;&lt;/a&gt;, 


is similar to the previous program, 
but uses nested &lt;code&gt;for&lt;/code&gt; loops to search for a value in a two-dimensional array. 
When the value is found, a labeled &lt;code&gt;break&lt;/code&gt; terminates the outer &lt;code&gt;for&lt;/code&gt; loop (labeled &quot;search&quot;): 

&lt;blockquote&gt;
&lt;pre&gt;class BreakWithLabelDemo {
    public static void main(String[] args) {

        int[][] arrayOfInts = { { 32, 87, 3, 589 },
                                { 12, 1076, 2000, 8 },
                                { 622, 127, 77, 955 }
                              };
        int searchfor = 12;

        int i;
        int j = 0;
        boolean foundIt = false;

    search:
        for (i = 0; i &amp;lt; arrayOfInts.length; i++) {
            for (j = 0; j &amp;lt; arrayOfInts[i].length; j++) {
                if (arrayOfInts[i][j] == searchfor) {
                    foundIt = true;
                    break search;
                }
            }
        }

        if (foundIt) {
            System.out.println(&quot;Found &quot; + searchfor +
                               &quot; at &quot; + i + &quot;, &quot; + j);
        } else {
            System.out.println(searchfor
                               + &quot; not in the array&quot;);
        }
    }
}&lt;/pre&gt;
&lt;/blockquote&gt;
This is the output of the program.
&lt;br /&gt;
&lt;pre&gt;     Found 12 at 1, 0&lt;/pre&gt;
The &lt;code&gt;break&lt;/code&gt; statement terminates the labeled statement; it 
does not transfer the flow of control to the label. Control flow is 
transferred to the statement immediately following the labeled 
(terminated) statement.


&lt;h3&gt;
The &lt;code&gt;continue&lt;/code&gt; Statement&lt;/h3&gt;
The &lt;code&gt;continue&lt;/code&gt; statement skips the current iteration of a &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt; , or &lt;code&gt;do-while&lt;/code&gt; loop. 
The unlabeled form skips to the end of the innermost loop&#39;s body and evaluates the &lt;code&gt;boolean&lt;/code&gt; expression that controls the loop. 
The following program, 


&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ContinueDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ContinueDemo&lt;/code&gt;&lt;/a&gt;
, 
steps through a &lt;code&gt;String&lt;/code&gt;, counting the occurences of the letter &quot;p&quot;. 
If the current character is not a p, the &lt;code&gt;continue&lt;/code&gt; statement skips the rest of the loop and proceeds to the next character. 
If it &lt;i&gt;is&lt;/i&gt; a &quot;p&quot;, the program increments the letter count.

&lt;blockquote&gt;
&lt;pre&gt;class ContinueDemo {
    public static void main(String[] args) {

        String searchMe = &quot;peter piper picked a peck of pickled peppers&quot;;
        int max = searchMe.length();
        int numPs = 0;

        for (int i = 0; i &amp;lt; max; i++) {
            //interested only in p&#39;s
            if (searchMe.charAt(i) != &#39;p&#39;)
                continue;

            //process p&#39;s
            numPs++;
        }
        System.out.println(&quot;Found &quot; + numPs + &quot; p&#39;s in the string.&quot;);
    }
}&lt;/pre&gt;
&lt;/blockquote&gt;
Here is the output of this program:
&lt;blockquote&gt;
&lt;pre&gt;Found 9 p&#39;s in the string.&lt;/pre&gt;
&lt;/blockquote&gt;
To see this effect more clearly, try removing the &lt;code&gt;continue&lt;/code&gt; statement and recompiling. When you run the program again, the
count will be wrong, saying that it found 35 p&#39;s instead of 9.


A labeled &lt;code&gt;continue&lt;/code&gt; statement skips the current iteration of an outer loop marked with the given label. 
The following example program, &lt;code&gt;ContinueWithLabelDemo&lt;/code&gt;, uses nested loops to search for a substring within another string. 
Two nested loops are required: one to iterate over the substring and one to iterate over the string being searched. 
The following program, 

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ContinueWithLabelDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ContinueWithLabelDemo&lt;/code&gt;&lt;/a&gt;, uses the labeled form of continue to skip an iteration in the outer loop.

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class ContinueWithLabelDemo {
    public static void main(String[] args) {

        String searchMe = &quot;Look for a substring in me&quot;;
        String substring = &quot;sub&quot;;
        boolean foundIt = false;

        int max = searchMe.length() - substring.length();

    test:
        for (int i = 0; i &amp;lt;= max; i++) {
            int n = substring.length();
            int j = i;
            int k = 0;
            while (n-- != 0) {
                if (searchMe.charAt(j++)
                        != substring.charAt(k++)) {
                    continue test;
                }
            }
            foundIt = true;
                 break test;
        }
        System.out.println(foundIt ? &quot;Found it&quot; :
                                     &quot;Didn&#39;t find it&quot;);
    }
}&lt;/pre&gt;
&lt;/blockquote&gt;
Here is the output from this program.
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;     Found it&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
The &lt;code&gt;return&lt;/code&gt; Statement&lt;/h3&gt;
The last of the branching statements is the &lt;code&gt;return&lt;/code&gt; statement. 
The &lt;code&gt;return&lt;/code&gt; statement exits from the current method, and control flow returns to where the method was invoked. 
The &lt;code&gt;return&lt;/code&gt; statement has two forms: one that returns a value, and one that doesn&#39;t. 
To return a value, simply put the value (or an expression that calculates the value) after the &lt;code&gt;return&lt;/code&gt; keyword.

&lt;blockquote&gt;
&lt;pre&gt;     return ++count;&lt;/pre&gt;
&lt;/blockquote&gt;
The data type of the returned value must match the type of the method&#39;s
declared return value. When a method is declared &lt;code&gt;void&lt;/code&gt;,
use the form of &lt;code&gt;return&lt;/code&gt; that doesn&#39;t return a value.
&lt;blockquote&gt;
&lt;pre&gt;     return;&lt;/pre&gt;
&lt;/blockquote&gt;
The 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/javaOO/methods.html&quot; target=&quot;_top&quot;&gt;Classes and Objects&lt;/a&gt; lesson will cover everything you need to know about writing methods.



        &lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/4283779869694316536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javabranching-statement.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/4283779869694316536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/4283779869694316536'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javabranching-statement.html' title='Core Java:Branching statement'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-6519318853776643217</id><published>2011-01-15T14:28:00.000-08:00</published><updated>2011-01-15T14:28:28.768-08:00</updated><title type='text'>Core Java:Loop</title><content type='html'>&lt;div id=&quot;PageTitle&quot; style=&quot;color: red;&quot;&gt;
&lt;b&gt;Control Flow Statements&lt;/b&gt;&lt;/div&gt;
The statements inside your source files are generally executed from top to bottom, in the order that they appear. &lt;i&gt;Control flow statements&lt;/i&gt;,
however, break up the flow of execution by employing decision making, looping, and branching, enabling your program to &lt;i&gt;conditionally&lt;/i&gt; execute
particular blocks of code. This section describes 
the decision-making statements (&lt;code&gt;if-then&lt;/code&gt;, &lt;code&gt;if-then-else&lt;/code&gt;, &lt;code&gt;switch&lt;/code&gt;),
the looping statements (&lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;do-while&lt;/code&gt;), and the branching statements (&lt;code&gt;break&lt;/code&gt;, &lt;code&gt;continue&lt;/code&gt;, &lt;code&gt;return&lt;/code&gt;) supported by the Java programming language.&lt;br /&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
The if-then and if-then-else Statements&lt;/div&gt;
&lt;blockquote&gt;

&lt;h3&gt;

The &lt;code&gt;if-then&lt;/code&gt; Statement
&lt;/h3&gt;
The &lt;code&gt;if-then&lt;/code&gt; statement is the most basic of
all the control flow statements. It tells your program to execute a certain 
section of code &lt;i&gt;only if&lt;/i&gt; a particular test evaluates to &lt;code&gt;true&lt;/code&gt;.
For example, the &lt;code&gt;Bicycle&lt;/code&gt; class could allow the brakes to 
decrease the bicycle&#39;s speed &lt;i&gt;only if&lt;/i&gt; the bicycle is already in motion. One possible 
implementation of the &lt;code&gt;applyBrakes&lt;/code&gt; method could be as follows:

&lt;blockquote&gt;
&lt;pre&gt;void applyBrakes(){
     if (isMoving){  // the &quot;if&quot; clause: bicycle must be moving
          currentSpeed--; // the &quot;then&quot; clause: decrease current speed
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
If this test evaluates to &lt;code&gt;false&lt;/code&gt; (meaning that the bicycle is not in motion), 
control jumps to the end of the &lt;code&gt;if-then&lt;/code&gt; statement.  


In addition, the opening and closing braces are optional, provided 
that the &quot;then&quot; clause contains only one statement:
&lt;br /&gt;

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;void applyBrakes(){
     if (isMoving) currentSpeed--; // same as above, but without braces 
}&lt;/pre&gt;
&lt;/blockquote&gt;
Deciding when to omit the braces is a matter of personal taste.
Omitting them can make the code more brittle.  If a second statement
is later added to the &quot;then&quot; clause, a common mistake would be forgetting
to add the newly required braces.  The compiler cannot catch this sort
of error; you&#39;ll just get the wrong results.



&lt;br /&gt;
&lt;h3&gt;
The &lt;code&gt;if-then-else&lt;/code&gt; Statement&lt;/h3&gt;
The &lt;code&gt;if-then-else&lt;/code&gt; statement provides a secondary path of execution when an
&quot;if&quot; clause evaluates to &lt;code&gt;false&lt;/code&gt;. You could use an &lt;code&gt;if-then-else&lt;/code&gt;

statement in the &lt;code&gt;applyBrakes&lt;/code&gt; method to take some action if the brakes are applied
when the bicycle is not in motion. In this case, the action is to simply print an error message
stating that the bicycle has already stopped.

&lt;blockquote&gt;
&lt;pre&gt;void applyBrakes(){
     if (isMoving) {
          currentSpeed--;
     } else {
          System.err.println(&quot;The bicycle has already stopped!&quot;);
     } 
}&lt;/pre&gt;
&lt;/blockquote&gt;
The following program, 

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/IfElseDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;IfElseDemo&lt;/code&gt;&lt;/a&gt;, assigns a grade based on the 
value of a test score: an A for a score of 90% or above, a B for 
a score of 80% or above, and so on.

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class IfElseDemo {
    public static void main(String[] args) {

        int testscore = 76;
        char grade;

        if (testscore &amp;gt;= 90) {
            grade = &#39;A&#39;;
        } else if (testscore &amp;gt;= 80) {
            grade = &#39;B&#39;;
        } else if (testscore &amp;gt;= 70) {
            grade = &#39;C&#39;;
        } else if (testscore &amp;gt;= 60) {
            grade = &#39;D&#39;;
        } else {
            grade = &#39;F&#39;;
        }
        System.out.println(&quot;Grade = &quot; + grade);
    }
}&lt;/pre&gt;
&lt;/blockquote&gt;
The output from the program is:
&lt;blockquote&gt;
&lt;pre&gt;    Grade = C&lt;/pre&gt;
&lt;/blockquote&gt;
You may have noticed that the value of &lt;code&gt;testscore&lt;/code&gt; can satisfy more than 
one expression in the compound statement: &lt;code&gt;76 &amp;gt;= 70&lt;/code&gt; and 
&lt;code&gt;76 &amp;gt;= 60&lt;/code&gt;. However, 
 once a condition is satisfied, the 
appropriate statements are executed &lt;code&gt;(grade = &#39;C&#39;;)&lt;/code&gt; and 
the remaining conditions are not evaluated.



        &lt;/blockquote&gt;
&lt;br /&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
The switch Statement&lt;/div&gt;
&lt;blockquote&gt;

Unlike &lt;code&gt;if-then&lt;/code&gt; and &lt;code&gt;if-then-else&lt;/code&gt;, the &lt;code&gt;switch&lt;/code&gt; statement allows for any number of
possible execution paths. A &lt;code&gt;switch&lt;/code&gt; works with the 

&lt;code&gt;byte&lt;/code&gt;, &lt;code&gt;short&lt;/code&gt;, &lt;code&gt;char&lt;/code&gt;, and &lt;code&gt;int&lt;/code&gt; primitive data types.
It also works with &lt;i&gt;enumerated types&lt;/i&gt; (discussed in 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/javaOO/enum.html&quot; target=&quot;_top&quot;&gt;Classes and Inheritance&lt;/a&gt;)

 and a few special classes that &quot;wrap&quot; certain primitive types:

&lt;a class=&quot;APILink&quot; href=&quot;http://download.oracle.com/javase/7/docs/api/java/lang/Character.html&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;Character&lt;/code&gt;&lt;/a&gt;,
&lt;a class=&quot;APILink&quot; href=&quot;http://download.oracle.com/javase/7/docs/api/java/lang/Byte.html&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;Byte&lt;/code&gt;&lt;/a&gt;,
&lt;a class=&quot;APILink&quot; href=&quot;http://download.oracle.com/javase/7/docs/api/java/lang/Short.html&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;Short&lt;/code&gt;&lt;/a&gt;,
 and
&lt;a class=&quot;APILink&quot; href=&quot;http://download.oracle.com/javase/7/docs/api/java/lang/Integer.html&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;Integer&lt;/code&gt;&lt;/a&gt;
 (discussed in


&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/data/index.html&quot; target=&quot;_top&quot;&gt;Simple Data Objects&lt;/a&gt;

).

The following program, 

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/SwitchDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;SwitchDemo&lt;/code&gt;&lt;/a&gt;, 
declares an &lt;code&gt;int&lt;/code&gt; named &lt;code&gt;month&lt;/code&gt; whose value represents 
a month out of the year. 
The program displays the name of the month, based on the value of month, using the &lt;code&gt;switch&lt;/code&gt; 

statement.


&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class SwitchDemo {
    public static void main(String[] args) {

        int month = 8;
        switch (month) {
            case 1:  System.out.println(&quot;January&quot;); break;
            case 2:  System.out.println(&quot;February&quot;); break;
            case 3:  System.out.println(&quot;March&quot;); break;
            case 4:  System.out.println(&quot;April&quot;); break;
            case 5:  System.out.println(&quot;May&quot;); break;
            case 6:  System.out.println(&quot;June&quot;); break;
            case 7:  System.out.println(&quot;July&quot;); break;
            case 8:  System.out.println(&quot;August&quot;); break;
            case 9:  System.out.println(&quot;September&quot;); break;
            case 10: System.out.println(&quot;October&quot;); break;
            case 11: System.out.println(&quot;November&quot;); break;
            case 12: System.out.println(&quot;December&quot;); break;
            default: System.out.println(&quot;Invalid month.&quot;);break;
        }
    }
}&lt;/pre&gt;
&lt;/blockquote&gt;
In this case, &quot;August&quot; is printed to standard output.
&lt;br /&gt;


The body of a &lt;code&gt;switch&lt;/code&gt; statement is known as a &lt;i&gt;switch block&lt;/i&gt;. Any statement immediately contained by the 
&lt;code&gt;switch&lt;/code&gt; block may be labeled with one or more &lt;code&gt;case&lt;/code&gt; or &lt;code&gt;default&lt;/code&gt; labels.
The &lt;code&gt;switch&lt;/code&gt; statement evaluates its expression
and executes the appropriate &lt;code&gt;case&lt;/code&gt;. 

&lt;br /&gt;
 
Of course, you could also implement the same thing with
&lt;code&gt;if-then-else&lt;/code&gt; statements:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;int month = 8;
if (month == 1) {
    System.out.println(&quot;January&quot;);
} else if (month == 2) {
    System.out.println(&quot;February&quot;);
}
. . . // and so on&lt;/pre&gt;
&lt;/blockquote&gt;
Deciding whether to use &lt;code&gt;if-then-else&lt;/code&gt; statements or a &lt;code&gt;switch&lt;/code&gt; statement is sometimes 
a judgment call. You can decide which one to use based on readability and other factors. 
An &lt;code&gt;if-then-else&lt;/code&gt; statement can be used to make decisions based on ranges of values or conditions, 
whereas a &lt;code&gt;switch&lt;/code&gt; statement can make decisions based only on a single integer or 
enumerated value. 


Another point of interest is the &lt;code&gt;break&lt;/code&gt; statement after each &lt;code&gt;case&lt;/code&gt;. 
Each &lt;code&gt;break&lt;/code&gt; statement terminates the enclosing &lt;code&gt;switch&lt;/code&gt; statement.
Control flow continues with the first statement following the &lt;code&gt;switch&lt;/code&gt; block. 
The &lt;code&gt;break&lt;/code&gt; statements are necessary because without them, &lt;code&gt;case&lt;/code&gt; 

statements fall through; that is, without an explicit &lt;code&gt;break&lt;/code&gt;, control will flow 
sequentially through subsequent &lt;code&gt;case&lt;/code&gt; statements. The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/SwitchDemo2.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;SwitchDemo2&lt;/code&gt;&lt;/a&gt;, 

illustrates why it might be useful to have &lt;code&gt;case&lt;/code&gt; statements fall through:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class SwitchDemo2 {
    public static void main(String[] args) {

        int month = 2;
        int year = 2000;
        int numDays = 0;

        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                numDays = 31;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                numDays = 30;
                break;
            case 2:
                if ( ((year % 4 == 0) &amp;amp;&amp;amp; !(year % 100 == 0))
                     || (year % 400 == 0) )
                    numDays = 29;
                else
                    numDays = 28;
                break;
            default:
                System.out.println(&quot;Invalid month.&quot;);
                break;
        }
        System.out.println(&quot;Number of Days = &quot; + numDays);
    }&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;pre&gt;}&lt;/pre&gt;
&lt;/blockquote&gt;
This is the output from the program.
&lt;br /&gt;
&lt;pre&gt;    Number of Days = 29&lt;/pre&gt;
Technically, the final &lt;code&gt;break&lt;/code&gt; is not required because flow would fall out of 
the &lt;code&gt;switch&lt;/code&gt; statement anyway. However, we recommend using a &lt;code&gt;break&lt;/code&gt; so that 
modifying the code is easier and less error-prone. The &lt;code&gt;default&lt;/code&gt; section handles 
all values that aren&#39;t explicitly handled by one 
of the &lt;code&gt;case&lt;/code&gt; sections. 



        &lt;/blockquote&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
&lt;h1&gt;
The while and do-while Statements&lt;/h1&gt;
&lt;/div&gt;
&lt;blockquote&gt;

The &lt;code&gt;while&lt;/code&gt; statement continually executes a block of statements 
while a particular condition is &lt;code&gt;true&lt;/code&gt;. 

Its syntax can be expressed as:

&lt;blockquote&gt;
&lt;pre&gt;while (expression) {
     statement(s)
}&lt;/pre&gt;
&lt;/blockquote&gt;
The &lt;code&gt;while&lt;/code&gt; statement evaluates &lt;i&gt;expression&lt;/i&gt;, which must return a 
&lt;code&gt;boolean&lt;/code&gt; value. If the expression evaluates to &lt;code&gt;true&lt;/code&gt;, the &lt;code&gt;while&lt;/code&gt; 
statement executes the &lt;em&gt;statement&lt;/em&gt;(s) in the &lt;code&gt;while&lt;/code&gt; block. The &lt;code&gt;while&lt;/code&gt; 

statement continues testing the expression and executing its block until the expression 
 evaluates to &lt;code&gt;false&lt;/code&gt;. Using the &lt;code&gt;while&lt;/code&gt; statement to print the values
from 1 through 10 can be accomplished as in the following

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/WhileDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;WhileDemo&lt;/code&gt;&lt;/a&gt;
 program:

&lt;blockquote&gt;
&lt;pre&gt;class WhileDemo {
     public static void main(String[] args){
          int count = 1;
          while (count &amp;lt; 11) {
               System.out.println(&quot;Count is: &quot; + count);
               count++;
          }
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
You can implement an infinite loop using the &lt;code&gt;while&lt;/code&gt; statement
as follows:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;while (true){
    // your code goes here
}&lt;/pre&gt;
&lt;/blockquote&gt;
The Java programming language also provides a &lt;code&gt;do-while&lt;/code&gt; 
statement, which can be expressed as follows:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;do {
     statement(s)
} while (expression);&lt;/pre&gt;
&lt;/blockquote&gt;
The difference between &lt;code&gt;do-while&lt;/code&gt; and &lt;code&gt;while&lt;/code&gt; is
that &lt;code&gt;do-while&lt;/code&gt; evaluates its expression at the bottom of the loop
instead of the top.
Therefore, the statements within the &lt;code&gt;do&lt;/code&gt; block are always executed
at least once, as shown in the following 

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/DoWhileDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;DoWhileDemo&lt;/code&gt;&lt;/a&gt;
program:

&lt;blockquote&gt;
&lt;pre&gt;class DoWhileDemo {
     public static void main(String[] args){
          int count = 1;
          do {
               System.out.println(&quot;Count is: &quot; + count);
               count++;
          } while (count &amp;lt;= 11);
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;div id=&quot;PageTitle&quot;&gt;
The for Statement&lt;/div&gt;
&lt;blockquote&gt;

The &lt;code&gt;for&lt;/code&gt; statement provides a compact way to iterate over a range of values. Programmers often
refer to it as the &quot;for loop&quot; because of the way in which it repeatedly loops until a particular
condition is satisfied. The general form of the &lt;code&gt;for&lt;/code&gt; statement can be expressed as follows:
&lt;blockquote&gt;
&lt;pre&gt;for (&lt;em&gt;initialization&lt;/em&gt;; &lt;em&gt;termination&lt;/em&gt;; &lt;em&gt;increment&lt;/em&gt;) {
    &lt;em&gt;statement(s)&lt;/em&gt;
}&lt;/pre&gt;
&lt;/blockquote&gt;
When using this version of the &lt;code&gt;for&lt;/code&gt; statement, keep in mind that:
&lt;ul&gt;
&lt;li&gt;The &lt;em&gt;initialization&lt;/em&gt; expression initializes the 
loop; it&#39;s executed once, as the loop begins.  
&lt;/li&gt;
&lt;li&gt;When the &lt;em&gt;termination&lt;/em&gt; expression evaluates to &lt;code&gt;false&lt;/code&gt;, the loop terminates.


&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;increment&lt;/em&gt; expression is invoked after each 
iteration through the loop; it is perfectly acceptable for this expression
to increment &lt;i&gt;or&lt;/i&gt; decrement a value.
&lt;/li&gt;
&lt;/ul&gt;
The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ForDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ForDemo&lt;/code&gt;&lt;/a&gt;, uses the general form of the &lt;code&gt;for&lt;/code&gt; statement to 
print the numbers 1 through 10 to standard output:


&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class ForDemo {
     public static void main(String[] args){
          for(int i=1; i&amp;lt;11; i++){
               System.out.println(&quot;Count is: &quot; + i);
          }
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
The output of this program is:
&lt;blockquote&gt;
&lt;pre&gt;Count is: 1
Count is: 2
Count is: 3
Count is: 4
Count is: 5
Count is: 6
Count is: 7
Count is: 8
Count is: 9
Count is: 10&lt;/pre&gt;
&lt;/blockquote&gt;
Notice how the code declares a variable within the initialization 
expression. The scope of this variable extends from its 
declaration to the end of the block governed by the &lt;code&gt;for&lt;/code&gt; statement, so it can be 
used in the termination and increment expressions as well. If the variable that controls 
a &lt;code&gt;for&lt;/code&gt; statement is not needed outside of the loop, it&#39;s best to declare the 
variable in the initialization expression. The names &lt;code&gt;i&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, and &lt;code&gt;k&lt;/code&gt; 

are often used to control &lt;code&gt;for&lt;/code&gt; loops; declaring them within the 
initialization expression limits their life span and reduces errors.



The three expressions of the &lt;code&gt;for&lt;/code&gt; loop are optional; an infinite
loop can be created as follows:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;for ( ; ; ) {    // infinite loop
    
     // your code goes here
}&lt;/pre&gt;
&lt;/blockquote&gt;
The &lt;code&gt;for&lt;/code&gt; statement also has another form designed for iteration through 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/collections/index.html&quot; target=&quot;_top&quot;&gt;Collections&lt;/a&gt;
and 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html&quot; target=&quot;_top&quot;&gt;arrays&lt;/a&gt; 

This form is sometimes referred to as the &lt;i&gt;enhanced for&lt;/i&gt; statement, and can be used to make
your loops more compact and easy to read. To demonstrate, consider the following array, which holds the numbers 1 through 10: 

&lt;br /&gt;

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;int[] numbers = {1,2,3,4,5,6,7,8,9,10};&lt;/pre&gt;
&lt;/blockquote&gt;
The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/EnhancedForDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;EnhancedForDemo&lt;/code&gt;&lt;/a&gt;, uses the enhanced &lt;code&gt;for&lt;/code&gt; to loop through the array: 
&lt;br /&gt;


&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class EnhancedForDemo {
     public static void main(String[] args){
          int[] numbers = {1,2,3,4,5,6,7,8,9,10};
          for (int item : numbers) {
            System.out.println(&quot;Count is: &quot; + item);
          }
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
In this example, the variable &lt;code&gt;item&lt;/code&gt; holds the current value from the
numbers array. The output from this program is the same as before:


&lt;blockquote&gt;
&lt;pre&gt;Count is: 1
Count is: 2
Count is: 3
Count is: 4
Count is: 5
Count is: 6
Count is: 7
Count is: 8
Count is: 9&lt;/pre&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
The for Statement&lt;/div&gt;
&lt;blockquote&gt;

The &lt;code&gt;for&lt;/code&gt; statement provides a compact way to iterate over a range of values. Programmers often
refer to it as the &quot;for loop&quot; because of the way in which it repeatedly loops until a particular
condition is satisfied. The general form of the &lt;code&gt;for&lt;/code&gt; statement can be expressed as follows:
&lt;blockquote&gt;
&lt;pre&gt;for (&lt;em&gt;initialization&lt;/em&gt;; &lt;em&gt;termination&lt;/em&gt;; &lt;em&gt;increment&lt;/em&gt;) {
    &lt;em&gt;statement(s)&lt;/em&gt;
}&lt;/pre&gt;
&lt;/blockquote&gt;
When using this version of the &lt;code&gt;for&lt;/code&gt; statement, keep in mind that:
&lt;ul&gt;
&lt;li&gt;The &lt;em&gt;initialization&lt;/em&gt; expression initializes the 
loop; it&#39;s executed once, as the loop begins.  
&lt;/li&gt;
&lt;li&gt;When the &lt;em&gt;termination&lt;/em&gt; expression evaluates to &lt;code&gt;false&lt;/code&gt;, the loop terminates.


&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;increment&lt;/em&gt; expression is invoked after each 
iteration through the loop; it is perfectly acceptable for this expression
to increment &lt;i&gt;or&lt;/i&gt; decrement a value.
&lt;/li&gt;
&lt;/ul&gt;
The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ForDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ForDemo&lt;/code&gt;&lt;/a&gt;, uses the general form of the &lt;code&gt;for&lt;/code&gt; statement to 
print the numbers 1 through 10 to standard output:


&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class ForDemo {
     public static void main(String[] args){
          for(int i=1; i&amp;lt;11; i++){
               System.out.println(&quot;Count is: &quot; + i);
          }
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
The output of this program is:
&lt;blockquote&gt;
&lt;pre&gt;Count is: 1
Count is: 2
Count is: 3
Count is: 4
Count is: 5
Count is: 6
Count is: 7
Count is: 8
Count is: 9
Count is: 10&lt;/pre&gt;
&lt;/blockquote&gt;
Notice how the code declares a variable within the initialization 
expression. The scope of this variable extends from its 
declaration to the end of the block governed by the &lt;code&gt;for&lt;/code&gt; statement, so it can be 
used in the termination and increment expressions as well. If the variable that controls 
a &lt;code&gt;for&lt;/code&gt; statement is not needed outside of the loop, it&#39;s best to declare the 
variable in the initialization expression. The names &lt;code&gt;i&lt;/code&gt;, &lt;code&gt;j&lt;/code&gt;, and &lt;code&gt;k&lt;/code&gt; 

are often used to control &lt;code&gt;for&lt;/code&gt; loops; declaring them within the 
initialization expression limits their life span and reduces errors.



The three expressions of the &lt;code&gt;for&lt;/code&gt; loop are optional; an infinite
loop can be created as follows:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;for ( ; ; ) {    // infinite loop
    
     // your code goes here
}&lt;/pre&gt;
&lt;/blockquote&gt;
The &lt;code&gt;for&lt;/code&gt; statement also has another form designed for iteration through 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/collections/index.html&quot; target=&quot;_top&quot;&gt;Collections&lt;/a&gt;
and 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html&quot; target=&quot;_top&quot;&gt;arrays&lt;/a&gt; 

This form is sometimes referred to as the &lt;i&gt;enhanced for&lt;/i&gt; statement, and can be used to make
your loops more compact and easy to read. To demonstrate, consider the following array, which holds the numbers 1 through 10: 

&lt;br /&gt;

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;int[] numbers = {1,2,3,4,5,6,7,8,9,10};&lt;/pre&gt;
&lt;/blockquote&gt;
The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/EnhancedForDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;EnhancedForDemo&lt;/code&gt;&lt;/a&gt;, uses the enhanced &lt;code&gt;for&lt;/code&gt; to loop through the array: 
&lt;br /&gt;


&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class EnhancedForDemo {
     public static void main(String[] args){
          int[] numbers = {1,2,3,4,5,6,7,8,9,10};
          for (int item : numbers) {
            System.out.println(&quot;Count is: &quot; + item);
          }
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
In this example, the variable &lt;code&gt;item&lt;/code&gt; holds the current value from the
numbers array. The output from this program is the same as before:


&lt;blockquote&gt;
&lt;pre&gt;Count is: 1
Count is: 2
Count is: 3
Count is: 4
Count is: 5
Count is: 6
Count is: 7
Count is: 8
Count is: 9
Count is: 10&lt;/pre&gt;
&lt;/blockquote&gt;
We recommend using this form of the &lt;code&gt;for&lt;/code&gt; statement instead of
the general form whenever possible. 
        &lt;/blockquote&gt;
&lt;pre&gt;Count is: 10&lt;/pre&gt;
&lt;/blockquote&gt;
We recommend using this form of the &lt;code&gt;for&lt;/code&gt; statement instead of
the general form whenever possible. 
        &lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/6519318853776643217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaloop.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/6519318853776643217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/6519318853776643217'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaloop.html' title='Core Java:Loop'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-3296944617261095132</id><published>2011-01-15T14:24:00.001-08:00</published><updated>2011-01-15T14:24:57.071-08:00</updated><title type='text'>Core Java:Expressions, Statements, and Blocks</title><content type='html'>&lt;div id=&quot;PageTitle&quot; style=&quot;color: red;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Expressions, Statements, and Blocks&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote&gt;

Now that you understand variables and operators, it&#39;s time to learn about  
&lt;i&gt;expressions&lt;/i&gt;, &lt;i&gt;statements&lt;/i&gt;, and &lt;i&gt;blocks&lt;/i&gt;.
Operators may be used in building expressions, which compute values; 
expressions are the core components of statements; statements may be 
grouped into blocks.



&lt;h3&gt;
Expressions&lt;/h3&gt;
An &lt;em&gt;expression&lt;/em&gt; is a construct made up of variables, operators, and method invocations, which are constructed according to the 
syntax of the language, that evaluates to a single value. You&#39;ve already seen examples of expressions, illustrated in bold
 below: 
&lt;pre&gt;     &lt;code&gt;int &lt;strong&gt;cadence = 0&lt;/strong&gt;;&lt;/code&gt;
     &lt;code&gt;&lt;strong&gt;anArray[0] = 100&lt;/strong&gt;;&lt;/code&gt;
     &lt;code&gt;System.out.println(&lt;strong&gt;&quot;Element 1 at index 0: &quot; + anArray[0]&lt;/strong&gt;);&lt;/code&gt;

     &lt;code&gt;int &lt;strong&gt;result = 1 + 2&lt;/strong&gt;; // result is now 3&lt;/code&gt;
     &lt;code&gt;if(&lt;strong&gt;value1 == value2&lt;/strong&gt;) System.out.println(&lt;strong&gt;&quot;value1 == value2&quot;&lt;/strong&gt;);&lt;/code&gt;&lt;/pre&gt;
The data type of the value returned by an expression depends on the elements used in the expression. 
The expression &lt;code&gt;cadence  = 0&lt;/code&gt; returns an &lt;code&gt;int&lt;/code&gt; because the assignment operator returns a value of the same data type as its left-hand operand; in this case, &lt;code&gt;cadence&lt;/code&gt; is an &lt;code&gt;int&lt;/code&gt;. As you can see from the other expressions, an expression can return other types of values as well, such as &lt;code&gt;boolean&lt;/code&gt; or &lt;code&gt;String&lt;/code&gt;.



The Java programming language allows you to construct compound 
expressions from various smaller expressions as long as the data type 
required by one part of the expression matches the data type of the 
other. Here&#39;s an example of a compound expression:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt; 
1 * 2 * 3&lt;/pre&gt;
&lt;/blockquote&gt;
In this particular example, the order in which the expression is 
evaluated is unimportant because the result of multiplication is 
independent of order; the outcome is always the same, no matter in which
 order you apply the multiplications. However, this is not true of all 
expressions. For example, the following expression gives different 
results, depending on whether you perform the addition or the division 
operation first:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;x + y / 100     // ambiguous&lt;/pre&gt;
&lt;/blockquote&gt;
You can specify exactly how an expression will be evaluated using 
balanced parenthesis: ( and ). For example, to make the previous 
expression unambiguous, you could write the following:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt; 
(x + y) / 100    // unambiguous, recommended&lt;/pre&gt;
&lt;/blockquote&gt;
If you don&#39;t explicitly indicate the order for the operations to be 
performed, the order is determined by the precedence assigned to the 
operators in use within the expression. Operators that have a higher 
precedence get evaluated first. For example, the division operator has a
 higher precedence than does the addition operator. Therefore, the 
following two statements are equivalent:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;x + y / 100 


x + (y / 100) // unambiguous, recommended&lt;/pre&gt;
&lt;/blockquote&gt;
When writing compound expressions, be explicit and indicate with 
parentheses which operators should be evaluated first. This practice 
makes code easier to read and to maintain.


&lt;br /&gt;
&lt;h3&gt;
Statements&lt;/h3&gt;
Statements are roughly equivalent to sentences in natural languages. 
A &lt;em&gt;statement&lt;/em&gt; forms a complete unit of execution. The following types of 
expressions can be made into a statement by terminating the expression with a 
semicolon (&lt;code&gt;;&lt;/code&gt;).

&lt;ul&gt;
&lt;li&gt; Assignment expressions

&lt;/li&gt;
&lt;li&gt; Any use of &lt;code&gt;++&lt;/code&gt; or &lt;code&gt;--&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt; Method invocations
&lt;/li&gt;
&lt;li&gt; Object creation expressions
&lt;/li&gt;
&lt;/ul&gt;
Such statements are called &lt;em&gt;expression statements&lt;/em&gt;. 
Here are some examples of expression statements.

&lt;blockquote&gt;
&lt;pre&gt;aValue = 8933.234;                      // assignment statement
aValue++;                               // increment statement
System.out.println(&quot;Hello World!&quot;);     // method invocation statement
Bicycle myBike = new Bicycle(); // object creation statement&lt;/pre&gt;
&lt;/blockquote&gt;
In addition to expression statements, there are 
two other kinds of statements: &lt;i&gt;declaration statements&lt;/i&gt; and &lt;i&gt;control flow statements&lt;/i&gt;. A &lt;em&gt;declaration statement&lt;/em&gt; 
declares a variable. You&#39;ve seen many examples of declaration statements already: 

&lt;blockquote&gt;
&lt;pre&gt;double aValue = 8933.234; //declaration statement&lt;/pre&gt;
&lt;/blockquote&gt;
Finally, &lt;em&gt;control flow statements&lt;/em&gt; regulate the order in which statements get executed. You&#39;ll learn about control flow statements
 in the next section,  

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/flow.html&quot; target=&quot;_top&quot;&gt;Control Flow Statements&lt;/a&gt;

&lt;h3&gt;
Blocks&lt;/h3&gt;
A &lt;i&gt;block&lt;/i&gt; is a group of zero or more statements between balanced braces and can be used anywhere a single statement is allowed. 
The following example,  

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/BlockDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;BlockDemo&lt;/code&gt;&lt;/a&gt;, illustrates the use of blocks:


&lt;blockquote&gt;

&lt;pre&gt;class BlockDemo {
     public static void main(String[] args) {
          boolean condition = true;
          if (condition) { &lt;strong&gt;// begin block 1&lt;/strong&gt;
               System.out.println(&quot;Condition is true.&quot;);
          } &lt;strong&gt;// end block one&lt;/strong&gt;
          else { &lt;strong&gt;// begin block 2&lt;/strong&gt;
               System.out.println(&quot;Condition is false.&quot;);
          } &lt;strong&gt;// end block 2&lt;/strong&gt;
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/3296944617261095132/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaexpressions-statements-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3296944617261095132'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3296944617261095132'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaexpressions-statements-and.html' title='Core Java:Expressions, Statements, and Blocks'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-4643226317928678517</id><published>2011-01-15T14:21:00.000-08:00</published><updated>2011-01-15T14:21:05.601-08:00</updated><title type='text'>Core Java:Operators</title><content type='html'>&lt;div id=&quot;PageTitle&quot; style=&quot;color: blue;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Operators&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;blockquote&gt;

Now that you&#39;ve learned how to declare and initialize variables, you 
probably want to know how to &lt;i&gt;do something&lt;/i&gt; with them. 
Learning the operators of the Java programming 
language is a good place to start. 
Operators are special symbols that perform specific operations on one, two, 
or three &lt;i&gt;operands&lt;/i&gt;, and then return a result.


As we explore the operators of the Java programming language, it may be 
helpful for you to know ahead of time which operators have
the highest precedence.
The operators in the following table are listed according to precedence 
order. The closer to the top of the table an operator appears, the 
higher its precedence. Operators with higher precedence are evaluated 
before operators with relatively lower precedence. Operators on the same
 line have equal precedence. When operators of equal precedence appear 
in the same expression, a rule must govern which is evaluated first. All
 binary operators except for the assignment operators are evaluated from
 left to right; assignment operators are evaluated right to left.

&lt;br /&gt;

&lt;br /&gt;
&lt;center&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; summary=&quot;This table lists operators according to precedence order&quot;&gt;
&lt;caption id=&quot;nutsandbolts-precedence&quot;&gt;&lt;strong&gt;
Operator Precedence
&lt;/strong&gt;&lt;/caption&gt;

&lt;tbody&gt;
&lt;tr&gt;&lt;th id=&quot;operator&quot;&gt;Operators&lt;/th&gt;&lt;th id=&quot;precedence&quot;&gt;Precedence&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;postfix&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;&lt;em&gt;expr&lt;/em&gt;++ &lt;em&gt;expr&lt;/em&gt;--&lt;/code&gt;&lt;/td&gt;

&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;unary&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;++&lt;em&gt;expr&lt;/em&gt; --&lt;em&gt;expr&lt;/em&gt; +&lt;em&gt;expr&lt;/em&gt; -&lt;em&gt;expr&lt;/em&gt; ~ !&lt;/code&gt;&lt;/td&gt;

&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;multiplicative&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;* / %&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;additive&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;+ -&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;shift&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;&amp;lt;&amp;lt; &amp;gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;

&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;relational&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= instanceof&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;equality&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;== !=&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;

 &lt;td headers=&quot;operator&quot;&gt;bitwise AND&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;&amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;bitwise exclusive OR&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;^&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;bitwise inclusive OR&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;|&lt;/code&gt;&lt;/td&gt;

&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;logical AND&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;logical OR&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;||&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;ternary&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;? :&lt;/code&gt;&lt;/td&gt;

&lt;/tr&gt;
&lt;tr&gt;
 &lt;td headers=&quot;operator&quot;&gt;assignment&lt;/td&gt;&lt;td headers=&quot;precedence&quot;&gt;&lt;code&gt;= += -= *= /= %= &amp;amp;= ^= |= &amp;lt;&amp;lt;= &amp;gt;&amp;gt;= &amp;gt;&amp;gt;&amp;gt;=&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/center&gt;






 In general-purpose programming, certain operators
tend to appear more frequently than others; for example, the assignment operator &quot;&lt;code&gt;=&lt;/code&gt;&quot;
is far more common than the unsigned right shift operator &quot;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;&quot;. With that in 
mind, the following discussion focuses first on the operators that 
you&#39;re most likely to use on a regular basis, and 
 ends focusing on those that are less common. 
Each discussion is accompanied by sample code 
that you can compile and run. Studying its output will help reinforce what you&#39;ve
just learned.


        &lt;/blockquote&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
Assignment, Arithmetic, and Unary Operators&lt;/div&gt;
&lt;blockquote&gt;

&lt;b&gt;The Simple Assignment Operator&lt;/b&gt;

One of the most common operators that you&#39;ll encounter 
is the simple assignment operator &quot;&lt;code&gt;=&lt;/code&gt;&quot;.
You saw this operator in the Bicycle class; it assigns the
value on its right to the operand on its left:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt; int cadence = 0;
 int speed = 0;
 int gear = 1;&lt;/pre&gt;
&lt;/blockquote&gt;
This operator can also be used on objects to assign
&lt;i&gt;object references&lt;/i&gt;, as discussed in 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/javaOO/objectcreation.html&quot; target=&quot;_top&quot;&gt;Creating Objects&lt;/a&gt;.



&lt;br /&gt;

&lt;b&gt;The Arithmetic Operators&lt;/b&gt;
&lt;br /&gt;

The Java programming language provides operators that perform 
addition, subtraction, multiplication, and division. 
There&#39;s a good chance you&#39;ll recognize them by their counterparts 
in basic mathematics. 
The only symbol that might look new to you is &quot;&lt;code&gt;%&lt;/code&gt;&quot;, which divides one operand by another and returns 
the remainder as its result.

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;+  additive operator (also used for String concatenation)
-  subtraction operator
* multiplication operator
/  division operator
% remainder operator&lt;/pre&gt;
&lt;/blockquote&gt;
The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ArithmeticDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ArithmeticDemo&lt;/code&gt;&lt;/a&gt;,
 tests the arithmetic operators.

&lt;blockquote&gt;
&lt;pre&gt;class ArithmeticDemo {

     public static void main (String[] args){
          
          int result = 1 + 2; // result is now 3
          System.out.println(result);

          result = result - 1; // result is now 2
          System.out.println(result);

          result = result * 2; // result is now 4
          System.out.println(result);

          result = result / 2; // result is now 2
          System.out.println(result);

          result = result + 8; // result is now 10
          result = result % 7; // result is now 3
          System.out.println(result);

     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
You can also combine the arithmetic operators with the simple assignment operator
to create &lt;i&gt;compound assignments&lt;/i&gt;.
For example, &lt;code&gt;x+=1;&lt;/code&gt; and &lt;code&gt;x=x+1;&lt;/code&gt; both increment the value 
of &lt;code&gt;x&lt;/code&gt; by 1.

The &lt;code&gt;+&lt;/code&gt; operator can also be used for concatenating (joining)
two strings together, as shown in the following 

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ConcatDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ConcatDemo&lt;/code&gt;&lt;/a&gt; program:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class ConcatDemo {
     public static void main(String[] args){
          String firstString = &quot;This is&quot;;
          String secondString = &quot; a concatenated string.&quot;;
          String thirdString = firstString+secondString;
          System.out.println(thirdString);
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
By the end of this program, the variable &lt;code&gt;thirdString&lt;/code&gt; 
contains &quot;This is a concatenated string.&quot;, which gets printed to standard output.



&lt;b&gt;The Unary Operators&lt;/b&gt;
&lt;br /&gt;

The unary operators require only one
operand; they perform various operations such as 
incrementing/decrementing a value by one,
negating an expression, or inverting the value of a boolean.

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;+  Unary plus operator; indicates positive value (numbers are positive without this, however)
-  Unary minus operator; negates an expression
++   Increment operator; increments a value by 1
--     Decrement operator; decrements a value by 1
!      Logical complement operator; inverts the value of a boolean&lt;/pre&gt;
&lt;/blockquote&gt;
The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/UnaryDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;UnaryDemo&lt;/code&gt;&lt;/a&gt;, tests the unary operators:
&lt;br /&gt;

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class UnaryDemo {

     public static void main(String[] args){
          int result = +1; // result is now 1
          System.out.println(result);
          result--;  // result is now 0
          System.out.println(result);
          result++; // result is now 1 
          System.out.println(result);
          result = -result; // result is now -1
          System.out.println(result);
          boolean success = false;
          System.out.println(success); // false
          System.out.println(!success); // true
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
The increment/decrement operators can be applied before (prefix) 
or after (postfix) the operand.
The code &lt;code&gt;result++;&lt;/code&gt; and &lt;code&gt;++result;&lt;/code&gt; will both
end in &lt;code&gt;result&lt;/code&gt; being incremented by one. The only difference is that 
the prefix version (&lt;code&gt;++result&lt;/code&gt;) evaluates to the incremented value, 

 whereas the postfix version (&lt;code&gt;result++&lt;/code&gt;)
evaluates to the original value. If you are just 
performing a simple increment/decrement, it doesn&#39;t really matter which version you choose. But if 
you use this operator in part of a larger expression, the one that you choose may make a 
significant difference.


The following program, 

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/PrePostDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;PrePostDemo&lt;/code&gt;&lt;/a&gt;, illustrates the prefix/postfix unary increment operator:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class PrePostDemo {
     public static void main(String[] args){
          int i = 3;
   i++;
   System.out.println(i); // &quot;4&quot;
   ++i;      
   System.out.println(i); // &quot;5&quot;
   System.out.println(++i); // &quot;6&quot;
   System.out.println(i++); // &quot;6&quot;
   System.out.println(i); // &quot;7&quot;
     }&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;pre&gt;}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
Equality, Relational, and Conditional Operators &lt;/div&gt;
&lt;blockquote&gt;

&lt;b&gt;The Equality and Relational Operators&lt;/b&gt;

The equality and relational operators determine if one operand is greater than, less than, equal to, 
or not equal to another operand. The majority of these operators will probably look familiar to 
you as well. Keep in mind that you must use &quot;&lt;code&gt;==&lt;/code&gt;&quot;, not &quot;&lt;code&gt;=&lt;/code&gt;&quot;, when testing if two
primitive values are equal.

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;== equal to
!= not equal to
&amp;gt; greater than
&amp;gt;= greater than or equal to
&amp;lt; less than
&amp;lt;= less than or equal to&lt;/pre&gt;
&lt;/blockquote&gt;
The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ComparisonDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ComparisonDemo&lt;/code&gt;&lt;/a&gt;,
 tests the comparison operators:

&lt;blockquote&gt;
&lt;pre&gt;class ComparisonDemo {

     public static void main(String[] args){
          int value1 = 1;
          int value2 = 2;
          if(value1 == value2) System.out.println(&quot;value1 == value2&quot;);
          if(value1 != value2) System.out.println(&quot;value1 != value2&quot;);
          if(value1 &amp;gt; value2) System.out.println(&quot;value1 &amp;gt; value2&quot;);
          if(value1 &amp;lt; value2) System.out.println(&quot;value1 &amp;lt; value2&quot;);
          if(value1 &amp;lt;= value2) System.out.println(&quot;value1 &amp;lt;= value2&quot;);
     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
Output:
&lt;blockquote&gt;
&lt;pre&gt;value1 != value2
value1 &amp;lt; value2
value1 &amp;lt;= value2&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;b&gt;The Conditional Operators&lt;/b&gt;
&lt;br /&gt;

The &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code&gt;||&lt;/code&gt; operators perform &lt;em&gt;Conditional-AND&lt;/em&gt; and 

&lt;em&gt;Conditional-OR&lt;/em&gt; operations
on two boolean expressions. These operators exhibit &quot;short-circuiting&quot; behavior, which means that the
second operand is evaluated only if needed. 

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;&amp;amp;&amp;amp; Conditional-AND
|| Conditional-OR&lt;/pre&gt;
&lt;/blockquote&gt;
The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ConditionalDemo1.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ConditionalDemo1&lt;/code&gt;&lt;/a&gt;, tests these operators:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class ConditionalDemo1 {

     public static void main(String[] args){
          int value1 = 1;
          int value2 = 2;
          if((value1 == 1) &amp;amp;&amp;amp; (value2 == 2)) System.out.println(&quot;value1 is 1 AND value2 is 2&quot;);
          if((value1 == 1) || (value2 == 1)) System.out.println(&quot;value1 is 1 OR value2 is 1&quot;);

     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
Another conditional operator is &lt;code&gt;?:&lt;/code&gt;, which can be thought of as 
shorthand for an &lt;code&gt;if-then-else&lt;/code&gt; statement (discussed in the 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/flow.html&quot; target=&quot;_top&quot;&gt;Control Flow Statements&lt;/a&gt;

section
of this lesson).
This operator is also known as the &lt;i&gt;ternary operator&lt;/i&gt; because it 
 uses three operands.


In the following example, this operator should be read as: &quot;If &lt;code&gt;someCondition&lt;/code&gt;

is &lt;code&gt;true&lt;/code&gt;, assign the value of &lt;code&gt;value1&lt;/code&gt; to &lt;code&gt;result&lt;/code&gt;. 
Otherwise, assign the value of &lt;code&gt;value2&lt;/code&gt; to &lt;code&gt;result&lt;/code&gt;.&quot;

&lt;br /&gt;

The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ConditionalDemo2.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ConditionalDemo2&lt;/code&gt;&lt;/a&gt;, tests the &lt;code&gt;?:&lt;/code&gt; operator:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class ConditionalDemo2 {

     public static void main(String[] args){
          int value1 = 1;
          int value2 = 2;
          int result;
          boolean someCondition = true;
          result = someCondition ? value1 : value2;

          System.out.println(result);

     }
}&lt;/pre&gt;
&lt;/blockquote&gt;
Because &lt;code&gt;someCondition&lt;/code&gt; is true, this program prints &quot;1&quot; to the screen.
Use the &lt;code&gt;?:&lt;/code&gt; operator instead of an &lt;code&gt;if-then-else&lt;/code&gt; statement if it makes your code more readable; for example, when the expressions
are compact and without side-effects (such as assignments).

&lt;br /&gt;

&lt;b&gt;The Type Comparison Operator instanceof&lt;/b&gt;
&lt;br /&gt;

The &lt;code&gt;instanceof&lt;/code&gt; operator compares an object to a specified type. 
You can use it to test if an object is
an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface. 

&lt;br /&gt;

The following program,

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/InstanceofDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;InstanceofDemo&lt;/code&gt;&lt;/a&gt;, 

 defines a parent class (named &lt;code&gt;Parent&lt;/code&gt;), a simple interface (named &lt;code&gt;MyInterface&lt;/code&gt;), and a child class (named &lt;code&gt;Child&lt;/code&gt;) that inherits from the parent and implements the interface.  

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class InstanceofDemo {
  public static void main(String[] args) {

    Parent obj1 = new Parent();
    Parent obj2 = new Child();

    System.out.println(&quot;obj1 instanceof Parent: &quot; + (obj1 instanceof Parent));
    System.out.println(&quot;obj1 instanceof Child: &quot; + (obj1 instanceof Child));
    System.out.println(&quot;obj1 instanceof MyInterface: &quot; + (obj1 instanceof MyInterface));
    System.out.println(&quot;obj2 instanceof Parent: &quot; + (obj2 instanceof Parent));
    System.out.println(&quot;obj2 instanceof Child: &quot; + (obj2 instanceof Child));
    System.out.println(&quot;obj2 instanceof MyInterface: &quot; + (obj2 instanceof MyInterface));
  }
}

class Parent{}
class Child extends Parent implements MyInterface{}
interface MyInterface{}&lt;/pre&gt;
&lt;/blockquote&gt;
Output: 

&lt;blockquote&gt;
&lt;pre&gt;obj1 instanceof Parent: true
obj1 instanceof Child: false
obj1 instanceof MyInterface: false
obj2 instanceof Parent: true
obj2 instanceof Child: true
obj2 instanceof MyInterface: true&lt;/pre&gt;
&lt;/blockquote&gt;
When using the &lt;code&gt;instanceof&lt;/code&gt; operator, keep in mind that &lt;code&gt;null&lt;/code&gt; is not an instance of anything.
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/4643226317928678517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaoperators.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/4643226317928678517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/4643226317928678517'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaoperators.html' title='Core Java:Operators'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-5524536365551321615</id><published>2011-01-15T14:18:00.001-08:00</published><updated>2011-01-15T14:18:35.123-08:00</updated><title type='text'>Core Java:Array</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
Arrays&lt;/div&gt;
&lt;blockquote&gt;

An &lt;i&gt;array&lt;/i&gt; is a container object that holds a fixed number of values
of a single type. 
The length of an array is established when the array is created. After creation, its length is fixed.
You&#39;ve seen an example of arrays already, in the &lt;code&gt;main&lt;/code&gt; method
of the &quot;Hello World!&quot; application. This section discusses arrays in greater detail.

&lt;br /&gt;
&lt;center&gt;

&lt;center&gt;&lt;img align=&quot;BOTTOM&quot; alt=&quot;Illustration of an array as 10 boxes numbered 0 through 9; an index of 0 indicates the first element in the array&quot; height=&quot;145&quot; src=&quot;http://download.oracle.com/javase/tutorial/figures/java/objects-tenElementArray.gif&quot; width=&quot;400&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;FigureCaption&quot;&gt;
An array of ten elements&lt;/div&gt;
&lt;/center&gt;
&lt;/center&gt;

Each item in an array is called an 
 &lt;i&gt;element&lt;/i&gt;, and each element is 
 accessed by its 
numerical &lt;i&gt;index&lt;/i&gt;. As shown in the above illustration, numbering begins
with 0. The 9th element, for example, would therefore be accessed at index 8.

&lt;br /&gt;

The following program, 

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ArrayDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ArrayDemo&lt;/code&gt;&lt;/a&gt;, 
creates an array of integers,
puts some values in it,
and prints each value to standard output.

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class ArrayDemo {
     public static void main(String[] args) {
          int[] anArray;              // declares an array of integers

          anArray = new int[10];      // allocates memory for 10 integers
            
          anArray[0] = 100; // initialize first element
          anArray[1] = 200; // initialize second element
          anArray[2] = 300; // etc.
          anArray[3] = 400;
          anArray[4] = 500;
          anArray[5] = 600;
          anArray[6] = 700;
          anArray[7] = 800;
          anArray[8] = 900;
          anArray[9] = 1000;

          System.out.println(&quot;Element at index 0: &quot; + anArray[0]);
          System.out.println(&quot;Element at index 1: &quot; + anArray[1]);
          System.out.println(&quot;Element at index 2: &quot; + anArray[2]);
          System.out.println(&quot;Element at index 3: &quot; + anArray[3]);
          System.out.println(&quot;Element at index 4: &quot; + anArray[4]);
          System.out.println(&quot;Element at index 5: &quot; + anArray[5]);
          System.out.println(&quot;Element at index 6: &quot; + anArray[6]);
          System.out.println(&quot;Element at index 7: &quot; + anArray[7]);
          System.out.println(&quot;Element at index 8: &quot; + anArray[8]);
          System.out.println(&quot;Element at index 9: &quot; + anArray[9]);
     }
} &lt;/pre&gt;
&lt;/blockquote&gt;
The output from this program is:

&lt;blockquote&gt;
&lt;pre&gt;Element at index 0: 100
Element at index 1: 200
Element at index 2: 300
Element at index 3: 400
Element at index 4: 500
Element at index 5: 600
Element at index 6: 700
Element at index 7: 800
Element at index 8: 900
Element at index 9: 1000&lt;/pre&gt;
&lt;/blockquote&gt;
In a real-world programming situation, you&#39;d probably use one of 
the supported &lt;i&gt;looping constructs&lt;/i&gt; to iterate through each 
element of the array, rather than write each line individually 
as shown above. However, this example clearly illustrates the array syntax.
You&#39;ll learn about the various looping constructs (&lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, and &lt;code&gt;do-while&lt;/code&gt;) in the 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/flow.html&quot; target=&quot;_top&quot;&gt;Control Flow&lt;/a&gt;
section.



&lt;br /&gt;
&lt;h3&gt;
Declaring a Variable to Refer to an Array&lt;/h3&gt;
The above program declares &lt;code&gt;anArray&lt;/code&gt; with the following line of code:
&lt;blockquote&gt;
&lt;pre&gt;int[] anArray;          // declares an array of integers&lt;/pre&gt;
&lt;/blockquote&gt;
Like declarations for variables of other types,
an array declaration has two components:
the array&#39;s type and the array&#39;s name.
An array&#39;s type is written as &lt;code&gt;&lt;em&gt;type&lt;/em&gt;[]&lt;/code&gt;,
where &lt;code&gt;&lt;em&gt;type&lt;/em&gt;&lt;/code&gt; is the data type
of the contained elements; the square brackets are special symbols
indicating that this variable holds an array. The size of the array is
not part of its type (which is why the brackets are empty). 
An array&#39;s name can be anything you want, provided that it follows the
rules and conventions as previously discussed in 
 the 
&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/variables.html#naming&quot; target=&quot;_top&quot;&gt;naming&lt;/a&gt; section. 
As with variables of other types, the declaration does not actually create an array — 
it simply tells the compiler that this variable will hold an array of the specified type.

&lt;br /&gt;

Similarly, you can declare arrays of other types:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;byte[] anArrayOfBytes;
short[] anArrayOfShorts;
long[] anArrayOfLongs;
float[] anArrayOfFloats;
double[] anArrayOfDoubles;
boolean[] anArrayOfBooleans;
char[] anArrayOfChars;
String[] anArrayOfStrings;&lt;/pre&gt;
&lt;/blockquote&gt;
You can also place
the square brackets after the array&#39;s name:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;float anArrayOfFloats[]; // this form is discouraged&lt;/pre&gt;
&lt;/blockquote&gt;
However, convention discourages this form; the brackets identify the
array type and should appear with the type designation.






&lt;br /&gt;
&lt;h3&gt;
Creating, Initializing, and Accessing an Array&lt;/h3&gt;
One way to create an array is with the &lt;code&gt;new&lt;/code&gt; operator.
The next statement in the &lt;code&gt;ArrayDemo&lt;/code&gt; program allocates
an array with enough memory for ten integer elements
and assigns the array to the &lt;code&gt;anArray&lt;/code&gt;
variable.
&lt;blockquote&gt;
&lt;pre&gt;anArray = new int[10];  // create an array of integers&lt;/pre&gt;
&lt;/blockquote&gt;
If this statement were missing,
the compiler would print an error like the following, and compilation
would fail:
&lt;blockquote&gt;
&lt;pre&gt;ArrayDemo.java:4: Variable anArray may not have been initialized.&lt;/pre&gt;
&lt;/blockquote&gt;
The next few lines assign values to each element of the array:

&lt;blockquote&gt;
&lt;pre&gt;anArray[0] = 100; // initialize first element
anArray[1] = 200; // initialize second element
anArray[2] = 300; // etc.&lt;/pre&gt;
&lt;/blockquote&gt;
Each array element is accessed by its numerical index:
&lt;blockquote&gt;
&lt;pre&gt;System.out.println(&quot;Element 1 at index 0: &quot; + anArray[0]);
System.out.println(&quot;Element 2 at index 1: &quot; + anArray[1]);
System.out.println(&quot;Element 3 at index 2: &quot; + anArray[2]);&lt;/pre&gt;
&lt;/blockquote&gt;
Alternatively, you can use the shortcut syntax to create and initialize an array:
&lt;blockquote&gt;
&lt;pre&gt;int[] anArray = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};&lt;/pre&gt;
&lt;/blockquote&gt;
Here the length of the array is determined by the number of values provided
between &lt;em&gt;{&lt;/em&gt; and &lt;em&gt;}&lt;/em&gt;.

You can also declare an array of arrays (also known as a
&lt;em&gt;multidimensional&lt;/em&gt; array) by using two or more sets of
square brackets, such as &lt;code&gt;String[][] names&lt;/code&gt;.
Each element, therefore, must be accessed by a corresponding
number of index values.
&lt;br /&gt;

In the Java programming language, a multidimensional array is
simply an array whose components are themselves arrays.
This is unlike arrays in C or Fortran.  A consequence of
this is that the rows are allowed to vary in length, as shown
in the following 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/MultiDimArrayDemo.java&quot; target=&quot;_top&quot;&gt;MultiDimArrayDemo&lt;/a&gt; program:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class MultiDimArrayDemo {
    public static void main(String[] args) {
        String[][] names = {{&quot;Mr. &quot;, &quot;Mrs. &quot;, &quot;Ms. &quot;},
                            {&quot;Smith&quot;, &quot;Jones&quot;}};
        System.out.println(names[0][0] + names[1][0]); //Mr. Smith
        System.out.println(names[0][2] + names[1][1]); //Ms. Jones
    }
}&lt;/pre&gt;
&lt;/blockquote&gt;
The output from this program is:
&lt;blockquote&gt;
&lt;pre&gt;    Mr. Smith
    Ms. Jones&lt;/pre&gt;
&lt;/blockquote&gt;
Finally, you can use the built-in &lt;code&gt;length&lt;/code&gt; property to 
determine the size of any array. 
The code
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt; System.out.println(anArray.length);&lt;/pre&gt;
&lt;/blockquote&gt;
will print the array&#39;s size to standard output.

&lt;h3&gt;
Copying Arrays&lt;/h3&gt;
The &lt;code&gt;System&lt;/code&gt; class has an &lt;code&gt;arraycopy&lt;/code&gt; method that you can use to efficiently copy data from one array into another: 
&lt;blockquote&gt;
&lt;pre&gt;public static void arraycopy(Object src,
                             int srcPos,
                             Object dest,
                             int destPos,
                             int length)&lt;/pre&gt;
&lt;/blockquote&gt;
The two &lt;code&gt;Object&lt;/code&gt; arguments specify the array to copy &lt;i&gt;from&lt;/i&gt; and the array to copy &lt;i&gt;to&lt;/i&gt;. The three &lt;code&gt;int&lt;/code&gt;
 arguments specify the starting position in the source array, the 
starting position in the destination array, and the number of array 
elements to copy. The following program, 

&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/ArrayCopyDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ArrayCopyDemo&lt;/code&gt;&lt;/a&gt;,
declares an array of &lt;code&gt;char&lt;/code&gt; elements, spelling the word &quot;decaffeinated&quot;. It uses &lt;code&gt;arraycopy&lt;/code&gt; to copy a subsequence of array components into a second array:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class ArrayCopyDemo {
    public static void main(String[] args) {
        char[] copyFrom = { &#39;d&#39;, &#39;e&#39;, &#39;c&#39;, &#39;a&#39;, &#39;f&#39;, &#39;f&#39;, &#39;e&#39;,
       &#39;i&#39;, &#39;n&#39;, &#39;a&#39;, &#39;t&#39;, &#39;e&#39;, &#39;d&#39; };
        char[] copyTo = new char[7];

        System.arraycopy(copyFrom, 2, copyTo, 0, 7);
        System.out.println(new String(copyTo));
    }
}&lt;/pre&gt;
&lt;/blockquote&gt;
The output from this program is:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;caffein&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/5524536365551321615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaarray.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/5524536365551321615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/5524536365551321615'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaarray.html' title='Core Java:Array'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-3058454111475022663</id><published>2011-01-15T14:17:00.000-08:00</published><updated>2011-01-15T14:17:45.769-08:00</updated><title type='text'>Core Java:Variables</title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Variables &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote&gt;
As you learned in the previous lesson, an object stores its state in &lt;i&gt;fields&lt;/i&gt;. 

&lt;blockquote&gt;

&lt;code&gt;
int &lt;b&gt;cadence&lt;/b&gt; = 0;&lt;br /&gt;

int &lt;b&gt;speed&lt;/b&gt; = 0;&lt;br /&gt;
int &lt;b&gt;gear&lt;/b&gt; = 1;
&lt;/code&gt;
&lt;/blockquote&gt;
The 
&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/concepts/object.html&quot; target=&quot;_top&quot;&gt;What Is an Object?&lt;/a&gt;
discussion introduced you to fields, but you probably
have still a few questions, such as: What are the rules and conventions for naming a field? 
Besides &lt;code&gt;int&lt;/code&gt;, what other data types are there? 
Do fields have to be initialized when they are declared? Are fields 
assigned
a default value if they are not explicitly initialized?
We&#39;ll explore the answers to such questions in this lesson, but before 
we do, there are a few technical distinctions you must first become 
aware of. In the
Java programming language, the terms &quot;field&quot; and &quot;variable&quot; are both 
used;
this is a common source of confusion among new developers, since both 
often seem to  refer to the same thing.
&lt;br /&gt;


The Java programming language defines the following kinds of variables:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Instance Variables (Non-Static Fields)&lt;/strong&gt; Technically speaking, objects store their individual states in &quot;non-static fields&quot;, that is, fields 
declared without the 
&lt;code&gt;static&lt;/code&gt; keyword. Non-static fields are also known as
&lt;i&gt;instance variables&lt;/i&gt; because their values are unique to each &lt;i&gt;instance&lt;/i&gt; of a class (to each object, in other words); the &lt;code&gt;currentSpeed&lt;/code&gt; of one bicycle is independent from the &lt;code&gt;currentSpeed&lt;/code&gt; of another. 




&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Class Variables (Static Fields)&lt;/strong&gt; A &lt;i&gt;class variable&lt;/i&gt; is any field declared with the 
&lt;code&gt;static&lt;/code&gt; modifier; this tells the compiler that there is 
exactly one copy of this variable in existence, regardless of how many 
times the class has been instantiated.
A field defining the number
of gears for a particular kind of bicycle could be marked as &lt;code&gt;static&lt;/code&gt; since conceptually the same number of gears 
 will apply to all instances. The code &lt;code&gt;static int numGears = 6;&lt;/code&gt; would create such a static field.
 Additionally, the keyword &lt;code&gt;final&lt;/code&gt; could be added to indicate that the number of gears will
never change.




&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Local Variables&lt;/strong&gt; Similar to how an object stores its state in fields, a method will often store its temporary state in &lt;i&gt;local variables&lt;/i&gt;.
The syntax for declaring a local variable is similar to declaring a field (for example, &lt;code&gt;int count = 0;&lt;/code&gt;).
There
 is no special keyword designating a variable as local; that 
determination 
comes entirely from the location in which the variable is declared —  
which is between the opening and closing braces of a method. As such, 
local
variables are only visible to the methods in which they are declared; 
they are not accessible from the rest of the class.



&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Parameters&lt;/strong&gt; You&#39;ve already seen examples of parameters, both in the &lt;code&gt;Bicycle&lt;/code&gt; class and in
the &lt;code&gt;main&lt;/code&gt; method of the &quot;Hello World!&quot; application. Recall that the signature for the &lt;code&gt;main&lt;/code&gt; method is &lt;code&gt;public static void main(String[] args)&lt;/code&gt;. Here, the &lt;code&gt;args&lt;/code&gt;
 variable is the
parameter to this method. The important thing to remember is that 
parameters are always classified as &quot;variables&quot;
not &quot;fields&quot;. This applies to other parameter-accepting constructs as 
well (such as constructors and exception handlers) that you&#39;ll learn 
about later in the tutorial.

&lt;/li&gt;
&lt;/ul&gt;
Having said that, the remainder of this tutorial uses the following 
general guidelines when discussing fields and variables. If we are 
talking
about &quot;fields in general&quot; (excluding local variables and parameters), we
 may simply say &quot;fields&quot;. If the discussion applies to &quot;all of the 
above&quot;, we may simply say &quot;variables&quot;. If the context calls for a 
distinction, we will use specific terms (static field, local variables, 
etc.) as appropriate.  
You may also occasionally see the term &quot;member&quot; used as well. 
A type&#39;s fields, methods, and nested types are collectively called
 its &lt;em&gt;members&lt;/em&gt;.


&lt;a href=&quot;&quot; name=&quot;naming&quot;&gt;
&lt;/a&gt;&lt;br /&gt;
&lt;h3&gt;
&lt;a href=&quot;&quot; name=&quot;naming&quot;&gt;Naming&lt;/a&gt;&lt;/h3&gt;
&lt;a href=&quot;&quot; name=&quot;naming&quot;&gt;Every programming language has its own set of rules and
 conventions for the kinds of names that you&#39;re allowed to use, and the 
Java programming language is no different. 
The rules and conventions for naming your variables can be summarized as
 follows:
 
&lt;/a&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;&quot; name=&quot;naming&quot;&gt;Variable names are case-sensitive. A variable&#39;s 
name can be any legal identifier — an unlimited-length sequence of 
Unicode letters and digits,  
 beginning with a letter, the dollar sign &quot;&lt;code&gt;$&lt;/code&gt;&quot;, or the underscore character &quot;&lt;code&gt;_&lt;/code&gt;&quot;. The convention, however, is to always
begin your variable names with a letter, not &quot;&lt;code&gt;$&lt;/code&gt;&quot; or &quot;&lt;code&gt;_&lt;/code&gt;&quot;.
 Additionally, the dollar sign character, by convention, is never used 
at all.


You may find some situations where auto-generated names will contain 
 the dollar sign, but your variable names should always
 avoid using it. A similar convention exists for the underscore 
character; while it&#39;s technically legal to begin your variable&#39;s name 
with &quot;&lt;code&gt;_&lt;/code&gt;&quot;, this practice is discouraged. White space is not permitted.


&lt;/a&gt;

&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;&quot; name=&quot;naming&quot;&gt;Subsequent characters may be letters, 
digits, dollar signs, or underscore characters. Conventions (and common 
sense) apply to this rule as well. When choosing a name for your 
variables, use full words instead of cryptic abbreviations.
Doing so will make your code easier to read and understand. 
In many cases it will also make your code self-documenting;
fields named &lt;code&gt;cadence&lt;/code&gt;, &lt;code&gt;speed&lt;/code&gt;, and &lt;code&gt;gear&lt;/code&gt;, for example, are much more intuitive than abbreviated versions, such as &lt;code&gt;s&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, and &lt;code&gt;g&lt;/code&gt;.
Also keep in mind that the name you choose must not be a 

&lt;/a&gt;&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html&quot; target=&quot;_top&quot;&gt;keyword or reserved word&lt;/a&gt;.

&lt;/li&gt;
&lt;li&gt;If the name you choose consists of only one word, spell that word in all
lowercase letters. If it consists of more than one word, capitalize the first
letter of each subsequent word. The names &lt;code&gt;gearRatio&lt;/code&gt; and 
&lt;code&gt;currentGear&lt;/code&gt; are prime examples of this convention. If your variable
stores a constant value, such as &lt;code&gt;static final int NUM_GEARS = 6&lt;/code&gt;,
the convention changes slightly, capitalizing every letter and 
separating subsequent words with the underscore character. By 
convention, the underscore character is never used elsewhere.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
Primitive Data Types&lt;/div&gt;
&lt;blockquote&gt;

The Java programming language is statically-typed,
which means that all variables must first be declared before they can be used.
This involves stating the variable&#39;s type and name, as you&#39;ve already seen:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;int gear = 1;&lt;/pre&gt;
&lt;/blockquote&gt;
Doing so tells your program that a field  named &quot;gear&quot; exists, holds 
numerical data, and has an initial value of &quot;1&quot;. A variable&#39;s data type determines the 
values it may contain, plus the operations that may be performed on it.  
In addition to &lt;code&gt;int&lt;/code&gt;, the Java programming language supports seven other &lt;i&gt;primitive
data types&lt;/i&gt;. A primitive type is predefined by the language and is 
named by a reserved keyword. Primitive values do not share state with 
other primitive values. 
The eight primitive data types supported by the Java programming 
language are:

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;byte&lt;/strong&gt;: The &lt;code&gt;byte&lt;/code&gt; data type is an 8-bit signed two&#39;s complement integer. It has a minimum
value of -128 and a maximum value of 127 (inclusive). The &lt;code&gt;byte&lt;/code&gt; data type can be useful for saving memory
in large 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html&quot; target=&quot;_top&quot;&gt;arrays&lt;/a&gt;, where the memory savings actually matters. They can also be used in place of

&lt;code&gt;int&lt;/code&gt; where their limits help to clarify your code; the fact that a variable&#39;s range is limited can 
serve as a form of documentation. 


&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;short&lt;/strong&gt;: The &lt;code&gt;short&lt;/code&gt; data type is a 16-bit signed two&#39;s complement integer. It has a 
minimum value of -32,768 and a maximum value of 32,767 (inclusive). As with &lt;code&gt;byte&lt;/code&gt;, the same guidelines apply:
you can use a &lt;code&gt;short&lt;/code&gt; to save memory in large arrays, in situations where the memory savings actually matters.
 

&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;int&lt;/strong&gt;: The &lt;code&gt;int&lt;/code&gt; data type is a 32-bit signed two&#39;s complement integer. It has a minimum value of
-2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). For integral values, this data type is generally 
the default choice unless there is a reason (like the above) to choose something else. This data type will most likely
be large enough for the numbers your program will use, but if you need a wider range of values, use &lt;code&gt;long&lt;/code&gt;

instead.
 


&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;long&lt;/strong&gt;: The &lt;code&gt;long&lt;/code&gt; data type is a 64-bit signed two&#39;s complement integer. It has a minimum value of 
-9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive). Use this data type when you need a
range of values wider than those provided by &lt;code&gt;int&lt;/code&gt;.


&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;float&lt;/strong&gt;: The &lt;code&gt;float&lt;/code&gt; data type is a single-precision 32-bit IEEE 754 floating point. 
Its range of values is beyond the scope of this discussion, but is specified in section 

&lt;a class=&quot;OutsideLink&quot; href=&quot;http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3&quot; target=&quot;_blank&quot;&gt;4.2.3&lt;/a&gt;
 of the Java Language Specification. As with the recommendations for &lt;code&gt;byte&lt;/code&gt; and &lt;code&gt;short&lt;/code&gt;, use a &lt;code&gt;float&lt;/code&gt; (instead of &lt;code&gt;double&lt;/code&gt;) if you need to save memory in large arrays
of floating point numbers. This data type should never be used for precise values, such as currency. For that, you will need to
use the 

&lt;a class=&quot;APILink&quot; href=&quot;http://download.oracle.com/javase/7/docs/api/java/math/BigDecimal.html&quot; target=&quot;_blank&quot;&gt;java.math.BigDecimal&lt;/a&gt;



class instead. 
&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/data/index.html&quot; target=&quot;_top&quot;&gt;Numbers and Strings&lt;/a&gt;

covers &lt;code&gt;BigDecimal&lt;/code&gt; and 
other useful classes provided by the Java platform.



&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;double&lt;/strong&gt;: The &lt;code&gt;double&lt;/code&gt; data type is a double-precision 64-bit IEEE 754 floating point.
Its range of values is beyond the scope of this discussion, but is specified in section 

&lt;a class=&quot;OutsideLink&quot; href=&quot;http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3&quot; target=&quot;_blank&quot;&gt;4.2.3&lt;/a&gt;

of the Java Language Specification. For decimal values, this data type is 
generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency. 


&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;boolean&lt;/strong&gt;: The &lt;code&gt;boolean&lt;/code&gt; data type has only two possible values: &lt;code&gt;true&lt;/code&gt; and 

&lt;code&gt;false&lt;/code&gt;. Use this data type for simple flags that track 
true/false conditions. This data type represents one bit of information,
 but its &quot;size&quot; isn&#39;t
something that&#39;s precisely defined.

&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;char&lt;/strong&gt;: The &lt;code&gt;char&lt;/code&gt; data type is a single 16-bit Unicode character. It has a minimum value of 
&lt;code&gt;&#39;\u0000&#39;&lt;/code&gt; (or 0) and a maximum value of &lt;code&gt;&#39;\uffff&#39;&lt;/code&gt; (or 65,535 inclusive). 
&lt;/li&gt;
&lt;/ul&gt;
In addition to the eight primitive data types listed above, the Java programming language also provides 
special support for character strings via the 

&lt;a class=&quot;APILink&quot; href=&quot;http://download.oracle.com/javase/7/docs/api/java/lang/String.html&quot; target=&quot;_blank&quot;&gt;java.lang.String&lt;/a&gt;



class. Enclosing your character string
within double quotes will automatically create a new &lt;code&gt;String&lt;/code&gt; object; for example, &lt;code&gt;String s = &quot;this is a string&quot;;&lt;/code&gt;.
&lt;code&gt;String&lt;/code&gt; objects are &lt;i&gt;immutable&lt;/i&gt;, which means that once created, their
values cannot be changed. The &lt;code&gt;String&lt;/code&gt; class is not technically a primitive data type, but considering the special 
support given to it by the language, you&#39;ll probably tend to think of it as such. You&#39;ll learn more about the &lt;code&gt;String&lt;/code&gt;

class in 

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/data/index.html&quot; target=&quot;_top&quot;&gt;Simple Data Objects&lt;/a&gt;
 
&lt;h3&gt;
Default Values&lt;/h3&gt;
It&#39;s not always necessary to assign a value when a field is declared. Fields that are declared but not initialized will be
set to a reasonable default by the compiler. Generally speaking, this default will be zero or &lt;code&gt;null&lt;/code&gt;, depending on the
data type. 
Relying on such default values, however, is generally considered bad programming style.


The following chart summarizes the default values for the above data types.

&lt;br /&gt;

&lt;br /&gt;
&lt;center&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align=&quot;LEFT&quot;&gt;&lt;strong&gt;Data Type&lt;/strong&gt;&lt;/td&gt;
&lt;td align=&quot;LEFT&quot;&gt;&lt;strong&gt;Default Value (for fields)&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;byte&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;short&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;int&lt;/td&gt;

&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;long&lt;/td&gt;
&lt;td&gt;0L&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;0.0f&lt;/td&gt;

&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;double&lt;/td&gt;
&lt;td&gt;0.0d&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;char&lt;/td&gt;
&lt;td&gt;&#39;\u0000&#39;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;

&lt;td&gt;String (or any object) &amp;nbsp;&lt;/td&gt;

&lt;td&gt;null&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;boolean&lt;/td&gt;
&lt;td&gt;false&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/center&gt;


Local variables are slightly different; the compiler never assigns a 
default value to an uninitialized local variable. 
If you cannot initialize your
local variable where it is declared, make sure to assign it a value 
before you attempt to use it. Accessing an uninitialized local variable 
will result in a compile-time error. 





















&lt;br /&gt;
&lt;h3&gt;
Literals&lt;/h3&gt;
You may have noticed that the &lt;code&gt;new&lt;/code&gt; keyword isn&#39;t used when initializing a 
variable of a primitive type. Primitive
types are special data types built into the language; they are not objects created
from a class.  A &lt;em&gt;literal&lt;/em&gt; is
 the source code representation of a fixed value; 
 literals are represented
directly in your code without requiring computation.
As shown below, 
it&#39;s  possible to 
 assign a literal to a variable of a primitive type:
&lt;br /&gt;
 
&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;     boolean result = true;
     char capitalC = &#39;C&#39;;
     byte b = 100; 
     short s = 10000; 
     int i = 100000; &lt;/pre&gt;
&lt;/blockquote&gt;
The integral types (&lt;code&gt;byte&lt;/code&gt;, &lt;code&gt;short&lt;/code&gt;, &lt;code&gt;int&lt;/code&gt;, and &lt;code&gt;long&lt;/code&gt;)  can be expressed using decimal, octal, or hexadecimal number systems. Decimal is the number system you already use every day;
it&#39;s based on 10 digits, numbered 0 through 9.
The octal number system is base 8, consisting of the digits 0 through 7. The hexadecimal system is base 16, 
whose digits are the numbers 0 through 9 and the letters A through F.   
For general-purpose programming, the decimal system is likely to be the only number system you&#39;ll ever use.  
However, if you need octal or hexadecimal, the following example shows 
the correct syntax. The prefix &lt;code&gt;0&lt;/code&gt; indicates octal, whereas &lt;code&gt;0x&lt;/code&gt; indicates hexadecimal.


&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;     int decVal = 26;  // The number 26, in decimal
     int octVal = 032;  // The number 26, in octal
     int hexVal = 0x1a; // The number 26, in hexadecimal&lt;/pre&gt;
&lt;/blockquote&gt;
The floating point types (&lt;code&gt;float&lt;/code&gt; and &lt;code&gt;double&lt;/code&gt;) can also be expressed using  E or e (for scientific notation),
F or f (32-bit float literal) and D or d (64-bit double literal; this is the default and by convention is omitted).
&lt;br /&gt;

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;     double d1 = 123.4;
     double d2 = 1.234e2; // same value as d1, but in scientific notation
     float f1  = 123.4f;&lt;/pre&gt;
&lt;/blockquote&gt;
Literals of types &lt;code&gt;char&lt;/code&gt; and &lt;code&gt;String&lt;/code&gt; may contain any Unicode
(UTF-16) characters.  If your editor and file system allow it, you can
use such characters directly in your code.  If not, you can use
a &quot;Unicode escape&quot; such as &lt;code&gt;&#39;\u0108&#39;&lt;/code&gt; (capital C with circumflex), or
  &lt;code&gt;&quot;S\u00ED se\u00F1or&quot;&lt;/code&gt; (Sí Señor in Spanish). Always use &#39;single quotes&#39; for &lt;code&gt;char&lt;/code&gt; literals
and &quot;double quotes&quot; for &lt;code&gt;String&lt;/code&gt; literals. 
Unicode escape sequences may be used
elsewhere in a program (such as in field names, for example), not just in &lt;code&gt;char&lt;/code&gt; or &lt;code&gt;String&lt;/code&gt; literals. 

&lt;br /&gt;

The Java programming language also supports a few special escape sequences for &lt;code&gt;char&lt;/code&gt; and &lt;code&gt;String&lt;/code&gt; literals: &lt;code&gt;\b&lt;/code&gt; (backspace), 
&lt;code&gt;\t&lt;/code&gt; (tab), &lt;code&gt;\n&lt;/code&gt; (line feed), &lt;code&gt;\f&lt;/code&gt; (form feed), &lt;code&gt;\r&lt;/code&gt; (carriage return), &lt;code&gt;\&quot;&lt;/code&gt; (double quote), &lt;code&gt;\&#39;&lt;/code&gt; (single quote), and &lt;code&gt;\\&lt;/code&gt; (backslash). 

&lt;br /&gt;


There&#39;s also a special &lt;code&gt;null&lt;/code&gt; literal that can be 
used as a value for any
reference type.  &lt;code&gt;null&lt;/code&gt; may be assigned to any variable, except
variables of primitive types.  There&#39;s little you can do with a &lt;code&gt;null&lt;/code&gt; 
value beyond testing for its presence. Therefore, &lt;code&gt;null&lt;/code&gt; is often
used in programs as a marker to indicate that some object is unavailable.
&lt;br /&gt;

Finally, there&#39;s also a special kind of literal called a &lt;em&gt;class literal&lt;/em&gt;, formed
by taking a type name and appending &quot;&lt;code&gt;.class&quot;&lt;/code&gt;; for example, &lt;code&gt;String.class&lt;/code&gt;.
This refers to the object (of type &lt;code&gt;Class&lt;/code&gt;) that represents the type itself.

        &lt;/blockquote&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/3058454111475022663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javavariables.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3058454111475022663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3058454111475022663'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javavariables.html' title='Core Java:Variables'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-3682956021302881146</id><published>2011-01-15T14:15:00.000-08:00</published><updated>2011-01-15T14:15:11.723-08:00</updated><title type='text'>Core Java:Language Basics</title><content type='html'>Language Basics
        &lt;br /&gt;
&lt;blockquote&gt;




&lt;h3&gt;

Variables&lt;/h3&gt;
&lt;blockquote&gt;

You&#39;ve already learned that objects store their state in fields. However, the Java 
programming language also uses the term &quot;variable&quot; as well. This section discusses 
this relationship, plus variable naming rules and conventions, 
basic data types (primitive types, character strings, and arrays), default values, and literals.

&lt;/blockquote&gt;
&lt;h3&gt;

Operators&lt;/h3&gt;
&lt;blockquote&gt;

This section describes the operators of the Java programming language. It presents the most
commonly-used operators first, and the less commonly-used operators last. Each discussion 
includes code samples that you can compile and run.



&lt;/blockquote&gt;
&lt;h3&gt;

Expressions, Statements, and Blocks&lt;/h3&gt;
&lt;blockquote&gt;


  Operators may be used in building expressions, which compute values; 
expressions are the core components of statements; statements may be 
grouped into blocks.
 
This section discusses expressions, statements, and blocks using example
 code that you&#39;ve already 
seen.
&lt;/blockquote&gt;
&lt;h3&gt;

Control Flow Statements&lt;/h3&gt;
&lt;blockquote&gt;

This section describes the control flow statements supported by the Java programming language.
It covers the decisions-making, looping, and branching statements that enable your programs to conditionally
execute particular blocks of code.


&lt;/blockquote&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/3682956021302881146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javalanguage-basics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3682956021302881146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3682956021302881146'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javalanguage-basics.html' title='Core Java:Language Basics'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-1784514453779888453</id><published>2011-01-15T14:10:00.001-08:00</published><updated>2011-01-15T14:10:50.434-08:00</updated><title type='text'>Core Java:Package</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
What Is a Package?&lt;/div&gt;
&lt;blockquote&gt;

A package is a namespace that organizes a set of related classes and 
interfaces. 
Conceptually you can think of packages as being similar to different 
folders on your computer. You might keep HTML pages in one folder, 
images in another, and 
scripts or applications in yet another.
Because software written in the Java programming language can be 
composed of hundreds or &lt;i&gt;thousands&lt;/i&gt; of individual classes, it makes sense to keep things organized by placing related classes and interfaces into packages. 


The Java platform provides an enormous class library (a set of packages)
 suitable for use in your own applications. This library is known as the
 &quot;Application Programming Interface&quot;, or &quot;API&quot; for short. Its packages 
represent the tasks most commonly associated with general-purpose 
programming. For example, a &lt;code&gt;String&lt;/code&gt; object contains state and behavior for character strings; a
&lt;code&gt;File&lt;/code&gt; object allows a programmer to easily create, delete, inspect, compare, or modify a file on the filesystem; a &lt;code&gt;Socket&lt;/code&gt;
 object allows for the creation and use of network sockets; various GUI 
objects control buttons and checkboxes and anything else related to 
graphical user interfaces. There are literally thousands of classes to 
choose from. This allows you, the programmer, to focus on the design of 
your particular application, rather than the 
infrastructure required to make it work. 

&lt;br /&gt;

The 

&lt;a class=&quot;APILink&quot; href=&quot;http://java.sun.com/javase/6/docs/api/index.html&quot; target=&quot;_blank&quot;&gt;Java Platform API Specification&lt;/a&gt;
contains the complete listing for all packages, interfaces, classes, 
fields, and methods supplied by the Java Platform 6, Standard Edition. 
Load the page in your browser and bookmark it. As a programmer, it will 
become your single most important piece of reference documentation.
        &lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/1784514453779888453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javapackage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/1784514453779888453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/1784514453779888453'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javapackage.html' title='Core Java:Package'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-4674548385365909560</id><published>2011-01-15T14:09:00.002-08:00</published><updated>2011-01-15T14:09:53.241-08:00</updated><title type='text'>Core Java:Inheritance</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
What Is Inheritance?&lt;/div&gt;
&lt;blockquote&gt;

Different kinds of objects often have a certain amount in common with 
each other. 
Mountain bikes, road bikes, and tandem bikes, for example, all share the
 characteristics of bicycles (current speed, current pedal cadence, 
current gear). Yet each also defines additional features that make them 
different: tandem bicycles have two seats and two sets of handlebars; 
road bikes have drop handlebars; some mountain bikes have an additional 
chain ring, giving them a lower gear ratio.


Object-oriented programming allows classes to &lt;i&gt;inherit&lt;/i&gt; commonly used state and 
behavior from other classes. In this example, &lt;code&gt;Bicycle&lt;/code&gt; now becomes the &lt;i&gt;superclass&lt;/i&gt; of 
&lt;code&gt;MountainBike&lt;/code&gt;, &lt;code&gt;RoadBike&lt;/code&gt;, and &lt;code&gt;TandemBike&lt;/code&gt;. 
In the Java programming language, each class is allowed to have one direct superclass, and each 
superclass has the potential for an unlimited number of &lt;i&gt;subclasses&lt;/i&gt;:





&lt;br /&gt;
&lt;center&gt;&lt;img align=&quot;BOTTOM&quot; alt=&quot;A diagram of classes in a hierarchy.&quot; height=&quot;316&quot; src=&quot;http://download.oracle.com/javase/tutorial/figures/java/concepts-bikeHeirarchy.gif&quot; width=&quot;400&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;FigureCaption&quot;&gt;
A hierarchy of bicycle classes.&lt;/div&gt;
&lt;/center&gt;






The syntax for creating a subclass is simple. At the beginning of your class declaration, use the &lt;code&gt;extends&lt;/code&gt; keyword, followed by the name of the class to inherit from:

&lt;br /&gt;
&lt;pre&gt;class MountainBike &lt;strong&gt;extends&lt;/strong&gt; Bicycle {

     // new fields and methods defining a mountain bike would go here

}&lt;/pre&gt;
This gives &lt;code&gt;MountainBike&lt;/code&gt; all the same fields and methods as &lt;code&gt;Bicycle&lt;/code&gt;,
 yet allows its code to focus exclusively on the features that make it 
unique. This makes code for your subclasses easy to read. However, you 
must take care to properly document the state and behavior that each 
superclass defines, since that code will not appear in the source file 
of each subclass. 








        &lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/4674548385365909560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javainheritance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/4674548385365909560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/4674548385365909560'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javainheritance.html' title='Core Java:Inheritance'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-6792428422612564564</id><published>2011-01-15T14:09:00.000-08:00</published><updated>2011-01-15T14:09:10.262-08:00</updated><title type='text'>Core Java:Class</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
What Is a Class?&lt;/div&gt;
&lt;blockquote&gt;

In the real world, you&#39;ll often find many individual objects all of the 
same kind.
There may be thousands of other bicycles in existence, all of the same 
make and model. Each bicycle was built from the same set of blueprints 
and therefore contains the same components.
In object-oriented terms, we say that your bicycle is an 
&lt;i&gt;instance&lt;/i&gt; of the &lt;i&gt;class of objects&lt;/i&gt; known as bicycles.
A &lt;i&gt;class&lt;/i&gt; is the blueprint from which individual objects are created.


The following 
&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/concepts/examples/Bicycle.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;Bicycle&lt;/code&gt;&lt;/a&gt;
 class is one possible implementation of a bicycle:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class Bicycle {

       int cadence = 0;
       int speed = 0;
       int gear = 1;

       void changeCadence(int newValue) {
            cadence = newValue;
       }

       void changeGear(int newValue) {
            gear = newValue;
       }

       void speedUp(int increment) {
            speed = speed + increment;   
       }

       void applyBrakes(int decrement) {
            speed = speed - decrement;
       }

       void printStates() {
            System.out.println(&quot;cadence:&quot;+cadence+&quot; speed:&quot;+speed+&quot; gear:&quot;+gear);
       }
}&lt;/pre&gt;
&lt;/blockquote&gt;
The syntax of the Java programming language will look new to you, but the design of this class is 
based on the previous discussion of bicycle objects. 
The fields &lt;code&gt;cadence&lt;/code&gt;, &lt;code&gt;speed&lt;/code&gt;, and &lt;code&gt;gear&lt;/code&gt; represent the object&#39;s state,
and the methods (&lt;code&gt;changeCadence&lt;/code&gt;, &lt;code&gt;changeGear&lt;/code&gt;, &lt;code&gt;speedUp&lt;/code&gt; etc.) define its interaction with the outside world.



You may have noticed that the &lt;code&gt;Bicycle&lt;/code&gt; class does not contain a &lt;code&gt;main&lt;/code&gt; method.
That&#39;s because it&#39;s not a complete application; it&#39;s just the blueprint for bicycles that might be &lt;i&gt;used&lt;/i&gt; in an application. 
The responsibility of creating and using new &lt;code&gt;Bicycle&lt;/code&gt; objects belongs to some other class in your application.
&lt;br /&gt;

 Here&#39;s a 
&lt;a class=&quot;SourceLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/concepts/examples/BicycleDemo.java&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;BicycleDemo&lt;/code&gt;&lt;/a&gt;
 class that creates two separate &lt;code&gt;Bicycle&lt;/code&gt; objects and invokes their methods:

&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;class BicycleDemo {
     public static void main(String[] args) {

          // Create two different Bicycle objects
          Bicycle bike1 = new Bicycle();
          Bicycle bike2 = new Bicycle();

          // Invoke methods on those objects
          bike1.changeCadence(50);
          bike1.speedUp(10);
          bike1.changeGear(2);
          bike1.printStates();

          bike2.changeCadence(50);
          bike2.speedUp(10);
          bike2.changeGear(2);
          bike2.changeCadence(40);
          bike2.speedUp(10);
          bike2.changeGear(3);
          bike2.printStates();
     }
}
&lt;/pre&gt;
&lt;/blockquote&gt;
The output of this test prints the ending pedal cadence, speed, and gear for the
two bicycles:
&lt;pre&gt;cadence:50 speed:10 gear:2
cadence:40 speed:20 gear:3&lt;/pre&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/6792428422612564564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaclass.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/6792428422612564564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/6792428422612564564'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaclass.html' title='Core Java:Class'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-5032001203699601468</id><published>2011-01-15T14:08:00.001-08:00</published><updated>2011-01-15T14:08:27.988-08:00</updated><title type='text'>Core Java:object</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
What Is an Object?&lt;/div&gt;
&lt;blockquote&gt;

Objects are key to understanding 
 &lt;i&gt;object-oriented&lt;/i&gt;
 technology. Look around right now and you&#39;ll find many examples of 
real-world objects: your dog, your desk, your television set, your 
bicycle.

Real-world objects share two characteristics: They all have &lt;i&gt;state&lt;/i&gt; and &lt;i&gt;behavior&lt;/i&gt;.
 Dogs have state (name, color, breed, hungry) and behavior (barking, 
fetching, wagging tail).
Bicycles also have state (current gear, current pedal cadence, current 
speed)
and behavior (changing gear, changing pedal cadence, applying brakes). 
Identifying the state and behavior for real-world objects is a great way
 to begin thinking in terms of object-oriented programming. 
&lt;br /&gt;

Take a minute right now to observe the real-world objects that are in 
your immediate area. For each object that you see, ask yourself two 
questions: &quot;What possible states can this object be in?&quot; and &quot;What 
possible behavior can this object perform?&quot;. Make sure to write down 
your observations.
As you do, you&#39;ll notice that real-world objects vary in complexity; 
your desktop lamp may have only two possible states (on and off) and two
 possible behaviors (turn on, turn off), but your desktop radio might 
have additional states (on, off, current volume, current station) and 
behavior (turn on, turn off, increase volume, decrease volume, seek, 
scan, and tune). You may also notice that some objects, in turn, will 
also contain other objects. These real-world observations all translate 
into the world of object-oriented programming.
 
&lt;br /&gt;

&lt;br /&gt;
&lt;center&gt;

&lt;center&gt;&lt;img align=&quot;BOTTOM&quot; alt=&quot;A circle with an inner circle filled with items, surrounded by gray wedges representing methods that allow access to the inner circle.&quot; height=&quot;210&quot; src=&quot;http://download.oracle.com/javase/tutorial/figures/java/concepts-object.gif&quot; width=&quot;345&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;FigureCaption&quot;&gt;
A software object.&lt;/div&gt;
&lt;/center&gt;
&lt;/center&gt;

Software objects are conceptually similar to real-world objects: they too consist of
state and related behavior. An object stores its state in 
  &lt;i&gt;fields&lt;/i&gt;
(variables in some programming languages)
and exposes its behavior through 
 &lt;i&gt;methods&lt;/i&gt;
(functions in some programming languages). Methods operate on an 
object&#39;s internal state and serve as the primary mechanism for 
object-to-object communication. Hiding internal state and requiring all 
interaction to be performed through an object&#39;s methods is known as
 &lt;i&gt;data encapsulation&lt;/i&gt;
 — a fundamental principle of object-oriented programming.

&lt;br /&gt;


Consider a bicycle, for example:
&lt;br /&gt;

&lt;br /&gt;
&lt;center&gt;

&lt;center&gt;&lt;img align=&quot;BOTTOM&quot; alt=&quot;A picture of an object, with bibycle methods and instance variables.&quot; height=&quot;218&quot; src=&quot;http://download.oracle.com/javase/tutorial/figures/java/concepts-bicycleObject.gif&quot; width=&quot;273&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;FigureCaption&quot;&gt;
A bicycle modeled as a software object.&lt;/div&gt;
&lt;/center&gt;
&lt;/center&gt;

By attributing state (current speed, current pedal cadence, and current 
gear) and providing methods for changing that state, the object remains 
in control of how the outside world is allowed to use it. For example, 
if the bicycle only has 6 gears, a method
to change gears could reject any value that is less than 1 or greater 
than 6.


Bundling code into individual software objects provides a number of benefits, including:

&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Modularity: The source code for an object can be written and 
maintained independently of the source code for other objects. Once 
created, an object can be easily passed around inside the system.

&lt;/li&gt;
&lt;li&gt;Information-hiding: By interacting only with an object&#39;s 
methods, the details of its internal implementation remain hidden from 
the outside world.

&lt;/li&gt;
&lt;li&gt;Code re-use: If an object already exists (perhaps written 
by another software developer),
you can use that object in your program. This allows specialists to 
implement/test/debug complex, task-specific objects, which you 
can then trust to run in your own code.

&lt;/li&gt;
&lt;li&gt;Pluggability and debugging ease: If a particular object turns out to be problematic, you can simply 
remove it from your application and plug in a different object as its replacement. 
This is analogous to fixing mechanical problems in the real world. If a bolt breaks, you replace &lt;i&gt;it&lt;/i&gt;, not the entire machine.

&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/5032001203699601468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaobject.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/5032001203699601468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/5032001203699601468'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaobject.html' title='Core Java:object'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-4402814125255597325</id><published>2011-01-15T14:07:00.000-08:00</published><updated>2011-01-15T14:07:16.132-08:00</updated><title type='text'>Core Java:Object-Oriented Programming Concepts</title><content type='html'>Object-Oriented Programming Concepts
        &lt;br /&gt;
&lt;blockquote&gt;

 If you&#39;ve never used an object-oriented programming language before, 
you&#39;ll need to learn a few basic concepts before 
you can begin writing any code. This lesson will introduce you to objects,
classes, inheritance, interfaces, and packages.
Each discussion focuses on how these concepts relate to the real world,
while  simultaneously providing an introduction to the syntax of the
Java programming language.


 

&lt;h3&gt;

What Is an Object?&lt;/h3&gt;
&lt;blockquote&gt;

An object is a software bundle of related state and behavior.
Software objects are often used to model the real-world objects that you
 find in everyday life. This lesson explains how state and behavior are 
represented 
within an object, introduces the concept of 
data encapsulation, and explains the benefits of designing your software
 
in this manner. 
&lt;/blockquote&gt;
&lt;h3&gt;

What Is a Class?&lt;/h3&gt;
&lt;blockquote&gt;

A class is a blueprint or prototype from which objects are created. 
This section defines a class 
that models the state and behavior of a real-world object. 
It intentionally focuses on the basics, 
 showing how even a simple class can cleanly model state and behavior.
&lt;/blockquote&gt;
&lt;h3&gt;

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/java/concepts/inheritance.html&quot; target=&quot;_top&quot;&gt;What Is Inheritance?&lt;/a&gt;&lt;/h3&gt;
&lt;blockquote&gt;

Inheritance
provides a powerful and natural mechanism for organizing and structuring
your software. This section explains how classes inherit state and 
behavior from their superclasses, and explains how to derive one class 
from another using 
the simple syntax provided by the Java programming language.
&lt;/blockquote&gt;
&lt;h3&gt;

What Is an Interface?&lt;/h3&gt;
&lt;blockquote&gt;

An interface is a contract between a class and the outside world.
When a class implements an interface,
it promises to provide the behavior published by that interface.
This section defines a simple interface and explains the necessary 
changes for any class that implements it. 

&lt;/blockquote&gt;
&lt;h3&gt;

What Is a Package?&lt;/h3&gt;
&lt;blockquote&gt;

A package is a namespace for organizing classes
and interfaces in a logical manner. Placing your code into packages
makes large software projects easier to manage. This section
explains why this is useful, and introduces
 you to the Application Programming Interface (API) provided 
by the Java platform.
&lt;/blockquote&gt;
&lt;h3&gt;

Questions and Exercises: Object-Oriented Programming Concepts&lt;/h3&gt;
&lt;blockquote&gt;

Use the questions and exercises presented in this section to test your
understanding of objects, classes, inheritance, interfaces, and packages.
&lt;/blockquote&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/4402814125255597325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaobject-oriented-programming.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/4402814125255597325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/4402814125255597325'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaobject-oriented-programming.html' title='Core Java:Object-Oriented Programming Concepts'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-7510482833510990037</id><published>2011-01-15T14:05:00.000-08:00</published><updated>2011-01-15T14:05:03.206-08:00</updated><title type='text'>Core Java:&quot;Hello World!&quot; Application</title><content type='html'>&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:WordDocument&gt;
  &lt;w:View&gt;Normal&lt;/w:View&gt;
  &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
  &lt;w:TrackMoves/&gt;
  &lt;w:TrackFormatting/&gt;
  &lt;w:PunctuationKerning/&gt;
  &lt;w:ValidateAgainstSchemas/&gt;
  &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
  &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
  &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
  &lt;w:DoNotPromoteQF/&gt;
  &lt;w:LidThemeOther&gt;EN-US&lt;/w:LidThemeOther&gt;
  &lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt;
  &lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;
  &lt;w:Compatibility&gt;
   &lt;w:BreakWrappedTables/&gt;
   &lt;w:SnapToGridInCell/&gt;
   &lt;w:WrapTextWithPunct/&gt;
   &lt;w:UseAsianBreakRules/&gt;
   &lt;w:DontGrowAutofit/&gt;
   &lt;w:SplitPgBreakAndParaMark/&gt;
   &lt;w:DontVertAlignCellWithSp/&gt;
   &lt;w:DontBreakConstrainedForcedTables/&gt;
   &lt;w:DontVertAlignInTxbx/&gt;
   &lt;w:Word11KerningPairs/&gt;
   &lt;w:CachedColBalance/&gt;
  &lt;/w:Compatibility&gt;
  &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
  &lt;m:mathPr&gt;
   &lt;m:mathFont m:val=&quot;Cambria Math&quot;/&gt;
   &lt;m:brkBin m:val=&quot;before&quot;/&gt;
   &lt;m:brkBinSub m:val=&quot;--&gt;
   &lt;m:smallfrac m:val=&quot;off&quot;&gt;
   &lt;m:dispdef&gt;
   &lt;m:lmargin m:val=&quot;0&quot;&gt;
   &lt;m:rmargin m:val=&quot;0&quot;&gt;
   &lt;m:defjc m:val=&quot;centerGroup&quot;&gt;
   &lt;m:wrapindent m:val=&quot;1440&quot;&gt;
   &lt;m:intlim m:val=&quot;subSup&quot;&gt;
   &lt;m:narylim m:val=&quot;undOvr&quot;&gt;
  &lt;/m:narylim&gt;&lt;/m:intlim&gt;
&lt;/m:wrapindent&gt;&lt;!--[endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:LatentStyles DefLockedState=&quot;false&quot; DefUnhideWhenUsed=&quot;true&quot;
  DefSemiHidden=&quot;true&quot; DefQFormat=&quot;false&quot; DefPriority=&quot;99&quot;
  LatentStyleCount=&quot;267&quot;&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;0&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Normal&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;heading 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 7&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 8&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 9&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 7&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 8&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 9&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;35&quot; QFormat=&quot;true&quot; Name=&quot;caption&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;10&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Title&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;1&quot; Name=&quot;Default Paragraph Font&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;11&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtitle&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;22&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Strong&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;20&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Emphasis&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;59&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Table Grid&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; UnhideWhenUsed=&quot;false&quot; Name=&quot;Placeholder Text&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;1&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;No Spacing&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; UnhideWhenUsed=&quot;false&quot; Name=&quot;Revision&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;34&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;List Paragraph&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;29&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Quote&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;30&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Quote&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;19&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtle Emphasis&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;21&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Emphasis&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;31&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtle Reference&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;32&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Reference&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;33&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Book Title&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;37&quot; Name=&quot;Bibliography&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; QFormat=&quot;true&quot; Name=&quot;TOC Heading&quot;/&gt;
 &lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:&quot;Table Normal&quot;;
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-priority:99;
 mso-style-qformat:yes;
 mso-style-parent:&quot;&quot;;
 mso-padding-alt:0in 5.4pt 0in 5.4pt;
 mso-para-margin-top:0in;
 mso-para-margin-right:0in;
 mso-para-margin-bottom:10.0pt;
 mso-para-margin-left:0in;
 line-height:115%;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;}
&lt;/style&gt;
&lt;![endif]--&gt;

&lt;/m:defjc&gt;&lt;/m:rmargin&gt;&lt;/m:lmargin&gt;&lt;/m:dispdef&gt;&lt;/m:smallfrac&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Lesson: The &quot;Hello World!&quot;
Application&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;The sections listed below provide
detailed instructions for compiling and running a simple &quot;Hello
World!&quot; application. The first section provides information on getting
started with the NetBeans IDE, an integrated development environment that
greatly simplifies the software development process. The NetBeans IDE runs on
all of the platforms listed below. The remaining sections provide platform-specific
instructions for getting started without an integrated development environment.
If you run into problems, be sure to consult the common problems section; it
provides solutions for many issues encountered by new users. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/getStarted/cupojava/netbeans.html&quot; target=&quot;_top&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;Hello World!&quot; for the
NetBeans IDE&lt;/span&gt;&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 5pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;These instructions are for users of the NetBeans IDE. The
NetBeans IDE runs on the Java platform, which means that you can use it with
any operating system for which there is a JDK 6 available. These operating
systems include Microsoft Windows, Solaris OS, Linux, and Mac OS X. We
recommend using the NetBeans IDE instead of the command line whenever possible.
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/getStarted/cupojava/win32.html&quot; target=&quot;_top&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;Hello World!&quot; for Microsoft
Windows&lt;/span&gt;&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 5pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;These command-line instructions are for users of Windows XP
Professional, Windows XP Home, Windows Server 2003, Windows 2000 Professional,
and Windows Vista. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/getStarted/cupojava/unix.html&quot; target=&quot;_top&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;Hello World!&quot; for Solaris OS
and Linux&lt;/span&gt;&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 5pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;These command-line instructions are for users of Solaris OS
and Linux. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/getStarted/problems/index.html&quot; target=&quot;_top&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Common Problems (and Their Solutions)&lt;/span&gt;&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 5pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Consult this page if you have problems compiling or running
your application.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 5pt;&quot;&gt;
A Closer Look at the &quot;Hello World!&quot; Application
        &lt;/div&gt;
&lt;blockquote&gt;

Now that you&#39;ve seen the &quot;Hello World!&quot; application
(and perhaps even compiled and run it),
you might be wondering how it works.
Here again is its code:

&lt;blockquote&gt;
&lt;pre&gt;class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println(&quot;Hello World!&quot;); // Display the string.
    }
}&lt;/pre&gt;
&lt;/blockquote&gt;
The &quot;Hello World!&quot; application consists of three primary components: &lt;a href=&quot;http://download.oracle.com/javase/tutorial/getStarted/application/index.html#COMMENTS&quot;&gt;source code comments&lt;/a&gt;, &lt;a href=&quot;http://download.oracle.com/javase/tutorial/getStarted/application/index.html#CLASS_DEF&quot;&gt;the &lt;code&gt;HelloWorldApp&lt;/code&gt; class definition&lt;/a&gt;, and &lt;a href=&quot;http://download.oracle.com/javase/tutorial/getStarted/application/index.html#MAIN&quot;&gt; the &lt;code&gt;main&lt;/code&gt; method&lt;/a&gt;. 
The following explanation will provide you with a basic understanding
of the code, but the deeper implications will only become apparent
after you&#39;ve finished reading the rest of the tutorial.


&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;COMMENTS&quot;&gt;
&lt;/a&gt;&lt;h3&gt;
&lt;a href=&quot;&quot; name=&quot;COMMENTS&quot;&gt;Source Code Comments&lt;/a&gt;&lt;/h3&gt;
&lt;blockquote&gt;

&lt;a href=&quot;&quot; name=&quot;COMMENTS&quot;&gt;The following bold text defines the &lt;i&gt;comments&lt;/i&gt; of the &quot;Hello World!&quot; application: 
&lt;/a&gt;&lt;blockquote&gt;
&lt;pre&gt;&lt;a href=&quot;&quot; name=&quot;COMMENTS&quot;&gt;&lt;b&gt;/** 
 * The HelloWorldApp class implements an application that
 * simply prints &quot;Hello World!&quot; to standard output.
 */&lt;/b&gt;
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println(&quot;Hello World!&quot;); &lt;b&gt;// Display the string.&lt;/b&gt;
    }
}&lt;/a&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;COMMENTS&quot;&gt;Comments are ignored by the compiler but are
useful to other programmers. 
The Java programming language supports
three kinds of comments:
&lt;/a&gt;&lt;br /&gt;
&lt;blockquote&gt;

&lt;dl&gt;
&lt;dt&gt;&lt;a href=&quot;&quot; name=&quot;COMMENTS&quot;&gt; &lt;code&gt;/* &lt;em&gt;text&lt;/em&gt; */&lt;/code&gt;
&lt;/a&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;a href=&quot;&quot; name=&quot;COMMENTS&quot;&gt; The compiler ignores everything from
     &lt;code&gt;/*&lt;/code&gt; to
     &lt;code&gt;*/&lt;/code&gt;.
&lt;/a&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;a href=&quot;&quot; name=&quot;COMMENTS&quot;&gt; &lt;code&gt;/** &lt;em&gt;documentation&lt;/em&gt; */&lt;/code&gt;
&lt;/a&gt;&lt;/dt&gt;
&lt;dd&gt;&lt;a href=&quot;&quot; name=&quot;COMMENTS&quot;&gt; This indicates a documentation comment 
     (&lt;em&gt;doc comment&lt;/em&gt;, for short).
     The compiler ignores this kind of comment,
     just like it ignores comments that use
     &lt;code&gt;/*&lt;/code&gt; and
     &lt;code&gt;*/&lt;/code&gt;.
     The &lt;code&gt;javadoc&lt;/code&gt; tool uses doc comments
     when preparing automatically generated documentation.
     For more information on &lt;code&gt;javadoc&lt;/code&gt;, see the
     
&lt;/a&gt;&lt;a class=&quot;OutsideLink&quot; href=&quot;http://java.sun.com/javase/6/docs/technotes/guides/javadoc/index.html&quot; target=&quot;_blank&quot;&gt;Javadoc&lt;span&gt;&lt;sup&gt;TM&lt;/sup&gt;&lt;/span&gt; tool documentation&lt;/a&gt; .


&lt;/dd&gt;
&lt;dt&gt; &lt;code&gt;// &lt;em&gt;text&lt;/em&gt;&lt;/code&gt;
&lt;/dt&gt;
&lt;dd&gt; The compiler ignores everything from
     &lt;code&gt;//&lt;/code&gt; to the end of the line.
&lt;/dd&gt;&lt;/dl&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;CLASS_DEF&quot;&gt;
&lt;/a&gt;&lt;h3&gt;
&lt;a href=&quot;&quot; name=&quot;CLASS_DEF&quot;&gt;The &lt;code&gt;HelloWorldApp&lt;/code&gt; Class Definition&lt;/a&gt;&lt;/h3&gt;
&lt;blockquote&gt;



&lt;a href=&quot;&quot; name=&quot;CLASS_DEF&quot;&gt;The following 
 bold text begins the class definition block for the &quot;Hello World!&quot; application:

&lt;/a&gt;&lt;blockquote&gt;
&lt;pre&gt;&lt;a href=&quot;&quot; name=&quot;CLASS_DEF&quot;&gt;/** 
 * The HelloWorldApp class implements an application that
 * simply displays &quot;Hello World!&quot; to the standard output.
 */
&lt;b&gt;class HelloWorldApp {&lt;/b&gt;
    public static void main(String[] args) {
        System.out.println(&quot;Hello World!&quot;); // Display the string.
    }
&lt;b&gt;}&lt;/b&gt;&lt;/a&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;CLASS_DEF&quot;&gt;As shown above, the most basic form of a class definition is:
&lt;/a&gt;&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;&lt;a href=&quot;&quot; name=&quot;CLASS_DEF&quot;&gt;class &lt;em&gt;name&lt;/em&gt; {
    . . .
}&lt;/a&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;CLASS_DEF&quot;&gt;The keyword &lt;code&gt;class&lt;/code&gt; begins the class definition
for a class named &lt;code&gt;name&lt;/code&gt;,
and the code for each class appears between the opening and closing 
curly
braces marked in bold above. Chapter 2 provides an overview of classes 
in general, and Chapter 4 discusses classes in detail. For now it is 
enough to know that every application begins with a class definition.


&lt;/a&gt;&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;
&lt;/a&gt;&lt;h3&gt;
&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;The &lt;code&gt;main&lt;/code&gt; Method&lt;/a&gt;&lt;/h3&gt;
&lt;blockquote&gt;

&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;The following bold text begins 
the definition of the &lt;code&gt;main&lt;/code&gt; method:

&lt;/a&gt;&lt;blockquote&gt;
&lt;pre&gt;&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;/** 
 * The HelloWorldApp class implements an application that
 * simply displays &quot;Hello World!&quot; to the standard output.
 */
class HelloWorldApp {
    &lt;b&gt;public static void main(String[] args) {&lt;/b&gt;
        System.out.println(&quot;Hello World!&quot;); //Display the string.
    &lt;b&gt;}&lt;/b&gt;
}&lt;/a&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;In the Java programming language, every application
must contain a &lt;code&gt;main&lt;/code&gt; method whose signature is:
&lt;/a&gt;&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;public static void main(String[] args)&lt;/a&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;The modifiers &lt;code&gt;public&lt;/code&gt;
 and &lt;code&gt;static&lt;/code&gt; can 
be written in either order (&lt;code&gt;public static&lt;/code&gt; or &lt;code&gt;static public&lt;/code&gt;), but the convention
is to use &lt;code&gt;public static&lt;/code&gt; as shown above.
You can name the argument anything you want, but most programmers choose &quot;args&quot; 
or &quot;argv&quot;.
&lt;/a&gt;

&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;The &lt;code&gt;main&lt;/code&gt; method
is similar to the &lt;code&gt;main&lt;/code&gt; function in C and C++;
it&#39;s the entry point for your application
 and will subsequently invoke all the other methods required by your program.

&lt;/a&gt;&lt;br /&gt;


&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;The &lt;code&gt;main&lt;/code&gt; method accepts a single argument:
an array of elements of type &lt;code&gt;String&lt;/code&gt;.

&lt;/a&gt;&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;public static void main(&lt;b&gt;String[] args&lt;/b&gt;)&lt;/a&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;This array is the mechanism through which the runtime system
passes information to your application.  For example:
&lt;/a&gt;&lt;blockquote&gt;
&lt;pre&gt;&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;java &lt;em&gt;MyApp&lt;/em&gt; &lt;em&gt;arg1&lt;/em&gt; &lt;em&gt;arg2&lt;/em&gt;&lt;/a&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;Each string in the array is called a &lt;em&gt;command-line argument&lt;/em&gt;.
Command-line arguments let users
affect the operation of the application without recompiling it.
For example, a sorting program might allow the user
to specify that the data be sorted in descending
order with this command-line argument:
&lt;/a&gt;&lt;blockquote&gt;
&lt;pre&gt;&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;-descending&lt;/a&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;The &quot;Hello World!&quot; application ignores its command-line arguments,
but you should be aware of the fact that such arguments do exist.
&lt;/a&gt;&lt;br /&gt;

&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;Finally, the line:
&lt;/a&gt;&lt;br /&gt;
&lt;blockquote&gt;
&lt;pre&gt;&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;System.out.println(&quot;Hello World!&quot;);&lt;/a&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;a href=&quot;&quot; name=&quot;MAIN&quot;&gt;uses the &lt;code&gt;System&lt;/code&gt; class from the core library 
to print the &quot;Hello World!&quot; message to standard output. Portions of this
 library (also known as the &quot;Application Programming Interface&quot;, or 
&quot;API&quot;) will be discussed throughout the remainder of the tutorial. 

&lt;/a&gt;&lt;/blockquote&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 5pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/7510482833510990037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javahello-world-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/7510482833510990037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/7510482833510990037'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javahello-world-application.html' title='Core Java:&quot;Hello World!&quot; Application'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-5941676898154710414</id><published>2011-01-15T13:58:00.000-08:00</published><updated>2011-01-15T13:59:28.137-08:00</updated><title type='text'>Core Java:About the Java Technology</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
About the Java Technology&lt;/div&gt;
&lt;blockquote&gt;
Java technology is both a programming language and a platform.

&lt;/blockquote&gt;
&lt;h3&gt;

The Java Programming Language&lt;/h3&gt;
&lt;blockquote&gt;
The Java
 programming language is a high-level language that can be characterized 
by all of the following buzzwords:
&lt;br /&gt;
&lt;blockquote&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt; &lt;td&gt;&lt;br /&gt;
&lt;li&gt;Simple&lt;/li&gt;
&lt;/td&gt;&lt;td&gt;&lt;br /&gt;
&lt;li&gt;Architecture neutral&lt;/li&gt;
&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;&lt;br /&gt;
&lt;li&gt;Object oriented&lt;/li&gt;
&lt;/td&gt;&lt;td&gt;&lt;br /&gt;
&lt;li&gt;Portable&lt;/li&gt;
&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;&lt;br /&gt;
&lt;li&gt;Distributed&lt;/li&gt;
&lt;/td&gt;&lt;td&gt;&lt;br /&gt;
&lt;li&gt;High performance&lt;/li&gt;
&lt;/td&gt; &lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;&lt;br /&gt;
&lt;li&gt;Multithreaded&lt;/li&gt;
&lt;/td&gt; &lt;td&gt;&lt;br /&gt;
&lt;li&gt;Robust&lt;/li&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt; &lt;td&gt;&lt;br /&gt;
&lt;li&gt;Dynamic&lt;/li&gt;
&lt;/td&gt;&lt;td&gt;&lt;br /&gt;
&lt;li&gt;Secure&lt;/li&gt;
&lt;/td&gt; &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/blockquote&gt;
Each of the preceding buzzwords is explained in

&lt;a class=&quot;OutsideLink&quot; href=&quot;http://java.sun.com/docs/white/langenv/&quot; target=&quot;_blank&quot;&gt;&lt;i&gt;The Java Language Environment&lt;/i&gt;&lt;/a&gt; , a white paper written by James Gosling and Henry McGilton.&lt;br /&gt;
In the Java programming language, all source code is first 
written in plain text 
files ending
with the &lt;code&gt;.java&lt;/code&gt; extension.  Those source files are then compiled 
into &lt;code&gt;.class&lt;/code&gt; files by the &lt;code&gt;javac&lt;/code&gt; 
compiler.
A &lt;code&gt;.class&lt;/code&gt; file does not contain code that 
is native to your processor;
it instead contains &lt;i&gt;bytecodes&lt;/i&gt; — the machine language of the Java Virtual Machine&lt;sup&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/getStarted/intro/definition.html#FOOT&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; (Java VM).



The &lt;code&gt;java&lt;/code&gt; launcher tool then runs your application with an instance of the Java Virtual Machine.

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/figures/getStarted/g1.gif&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img align=&quot;BOTTOM&quot; alt=&quot;Figure showing MyProgram.java, compiler, MyProgram.class, Java VM, and My Program running on a computer.&quot; border=&quot;0&quot; height=&quot;83&quot; src=&quot;http://download.oracle.com/javase/tutorial/figures/getStarted/g1.gif&quot; width=&quot;482&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;FigureCaption&quot;&gt;
&lt;/div&gt;
&lt;/center&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;FigureCaption&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;FigureCaption&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;FigureCaption&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; An overview of the software development process.&lt;/div&gt;
&lt;blockquote&gt;
&lt;br /&gt;
&lt;center&gt;&lt;/center&gt;


Because the Java VM is
 available on many different operating systems, 
the same &lt;code&gt;.class&lt;/code&gt; files are capable of running on Microsoft Windows, the Solaris &lt;sup&gt;TM&lt;/sup&gt; 
Operating System (Solaris OS), Linux, or Mac OS. Some virtual machines, 
such as the 

&lt;a class=&quot;OutsideLink&quot; href=&quot;http://java.sun.com/products/hotspot/&quot; target=&quot;_blank&quot;&gt;Java HotSpot virtual machine&lt;/a&gt;, perform additional steps at runtime
to give your application a performance boost. This include various
tasks such as 
finding performance bottlenecks and recompiling (to native code) 
frequently used sections of code.

&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;&lt;img align=&quot;BOTTOM&quot; alt=&quot;Figure showing source code, compiler, and Java VM&#39;s for Win32, Solaris OS/Linux, and Mac OS&quot; height=&quot;332&quot; src=&quot;http://download.oracle.com/javase/tutorial/figures/getStarted/helloWorld.gif&quot; width=&quot;346&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;FigureCaption&quot;&gt;
Through the Java VM, the same application is capable of running on multiple platforms.&lt;/div&gt;
&lt;/center&gt;

&lt;/blockquote&gt;
&lt;h3&gt;

The Java Platform&lt;/h3&gt;
&lt;blockquote&gt;
A &lt;i&gt;platform&lt;/i&gt; is the hardware or software environment in which a program 
runs. We&#39;ve already mentioned some of the most popular platforms like Microsoft Windows,
Linux, Solaris OS, and Mac OS. Most platforms can be described as a 
combination of the operating system and underlying hardware. The Java platform differs from 
most other platforms in that it&#39;s a software-only platform that runs on top of 
other hardware-based platforms.

The Java platform has two components:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;
The &lt;i&gt;Java Virtual Machine&lt;/i&gt; 
&lt;/li&gt;
&lt;li&gt;
The &lt;i&gt;Java Application Programming Interface&lt;/i&gt; (API)
&lt;/li&gt;
&lt;/ul&gt;
You&#39;ve already been introduced to the Java Virtual Machine; 
it&#39;s the base for the Java 
platform and is ported onto various hardware-based platforms.

The API is a large collection of ready-made software components that 
provide many useful capabilities.
It is grouped into libraries of related classes and 
interfaces; these libraries are known as &lt;i&gt;packages&lt;/i&gt;. The next section,

&lt;a class=&quot;TutorialLink&quot; href=&quot;http://download.oracle.com/javase/tutorial/getStarted/intro/cando.html&quot; target=&quot;_top&quot;&gt;What Can Java Technology Do?&lt;/a&gt;

highlights some of the functionality provided by the API.
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;center&gt;&lt;img align=&quot;BOTTOM&quot; alt=&quot;Figure showing MyProgram.java, API, Java Virtual Machine, and Hardware-Based Platform&quot; height=&quot;102&quot; src=&quot;http://download.oracle.com/javase/tutorial/figures/getStarted/g3.gif&quot; width=&quot;221&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;FigureCaption&quot;&gt;
The API and Java Virtual Machine insulate the program from the underlying hardware.&lt;/div&gt;
&lt;/center&gt;

As a platform-independent environment, the Java 
platform can be a bit slower than native code. However, 
advances in compiler and virtual machine technologies
are bringing 
performance close to that of native code without threatening portability.

&lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=5316342384202108452&amp;amp;postID=5941676898154710414&quot; name=&quot;FOOT&quot;&gt;

&lt;span style=&quot;font-size: small;&quot;&gt;The terms&quot;Java Virtual Machine&quot; and &quot;JVM&quot; mean a Virtual Machine for the Java platform.
&lt;/span&gt;&lt;/a&gt;&lt;/blockquote&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
&lt;h1&gt;
What Can Java Technology Do?&lt;/h1&gt;
&lt;/div&gt;
&lt;blockquote&gt;



The general-purpose, high-level Java 
programming language is a powerful software platform.
Every full implementation of the Java platform gives you the following features:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Development Tools&lt;/strong&gt;: The development tools 
provide everything you&#39;ll need for 
compiling, running, monitoring, debugging, and documenting your applications.
As a new developer, the main tools you&#39;ll be using are the &lt;code&gt;javac&lt;/code&gt; compiler,
the &lt;code&gt;java&lt;/code&gt; launcher, and the &lt;code&gt;javadoc&lt;/code&gt; documentation tool.

&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application Programming Interface (API)&lt;/strong&gt;: 
The API provides the core functionality of the Java programming
language. It offers a wide array of useful classes ready for use
in your own applications. It spans everything from basic objects,
to networking and security, to XML generation and database access, and 
more. The core API is very large; to get an overview of what it 
contains, consult 
the

&lt;a class=&quot;OutsideLink&quot; href=&quot;http://java.sun.com/javase/6/docs/index.html&quot; target=&quot;_blank&quot;&gt;Java SE Development Kit 6 (JDK&lt;span&gt;&lt;sup&gt;TM&lt;/sup&gt;&lt;/span&gt; 6) documentation&lt;/a&gt;.







&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deployment Technologies&lt;/strong&gt;: The JDK software provides standard
mechanisms such as
the Java Web Start software and Java Plug-In software for deploying your applications to end users.

&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;User Interface Toolkits&lt;/strong&gt;: The
Swing and Java 2D toolkits make it possible to create sophisticated 
Graphical User Interfaces (GUIs).

&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Integration Libraries&lt;/strong&gt;: Integration libraries
such as the Java IDL API, JDBC&lt;span&gt;&lt;sup&gt;TM&lt;/sup&gt;&lt;/span&gt; API,
Java Naming and Directory Interface&lt;span&gt;&lt;sup&gt;TM&lt;/sup&gt;&lt;/span&gt; 
(&quot;J.N.D.I.&quot;) API,
 Java RMI, and Java Remote Method Invocation over Internet Inter-ORB 
Protocol Technology (Java RMI-IIOP Technology) enable database access 
and manipulation
of remote objects.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
How Will Java Technology Change My Life?&lt;/div&gt;
&lt;blockquote&gt;

We can&#39;t promise you fame, fortune, or even a job 
if you learn the Java programming language.
Still, it is likely to make your programs 
better and requires less
effort than other languages. We believe that Java technology 
will help you do the
following:
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Get started quickly&lt;/strong&gt;:
Although the Java programming language is a powerful object-oriented 
language, it&#39;s easy to
learn, especially for programmers already 
familiar with C or C++.

&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write less code&lt;/strong&gt;:
Comparisons of program metrics (class counts, 
method counts, and so on)
suggest that a program written in the Java programming language can be 
four times smaller than
the same program written in C++.

&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write better code&lt;/strong&gt;:
The Java programming language encourages good coding 
practices, and automatic garbage
collection helps you avoid memory leaks. Its 
object orientation, its
JavaBeans&lt;span&gt;&lt;sup&gt;TM&lt;/sup&gt;&lt;/span&gt; component architecture, and its 
wide-ranging, easily
extendible API let you reuse existing, 
tested code and introduce
fewer bugs.

&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Develop programs more quickly&lt;/strong&gt;:
The Java programming language is simpler than C++, and as such, 
your development time could be up to twice as fast when writing in it. 
Your programs will also require fewer lines of code.

&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid platform dependencies&lt;/strong&gt;:
You can keep your program portable by avoiding 
the use of libraries
written in other languages. 


&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write once, run anywhere&lt;/strong&gt;:
Because applications written in the Java programming language are compiled into 
machine-independent
bytecodes, they run consistently on any Java 
platform.

&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distribute software more easily&lt;/strong&gt;:
With Java Web Start software, users will be able to launch your applications
with a single click of the mouse. 
An automatic version check at startup ensures that users are always up
to date with the latest version of your software. If an update is available, the Java Web Start
software will automatically update their installation. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/5941676898154710414/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaabout-java-technology.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/5941676898154710414'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/5941676898154710414'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/core-javaabout-java-technology.html' title='Core Java:About the Java Technology'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-2944235015197009014</id><published>2011-01-15T12:51:00.000-08:00</published><updated>2011-01-15T12:51:39.515-08:00</updated><title type='text'>JDBC:Using Stored Procedures</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
&lt;h1&gt;
Using Stored Procedures&lt;/h1&gt;
&lt;/div&gt;
&lt;blockquote&gt;

A stored procedure is a group of SQL statements that form a logical 
unit and perform a particular task, and they are used to encapsulate a 
set of operations or queries to execute on a database server. For 
example, operations on an employee database (hire, fire, promote, 
lookup) could be coded as stored procedures executed by application 
code. Stored procedures can be compiled and executed with different 
parameters and results, and they can have any combination of input, 
output, and input/output parameters. &lt;br /&gt;


Note that stored procedures are supported by most DBMSs, but there is
 a fair amount of variation in their syntax and capabilities. 
Consequently, the tutorial contains two classes, &lt;code&gt;StoredProcedureJavaDBSample&lt;/code&gt; and &lt;code&gt;StoredProcedureMySQLSample&lt;/code&gt; to demonstrate how to create stored procedures in Java DB and MySQL, respectively.&lt;br /&gt;


&lt;h3&gt;
Overview of Creating Stored Procedures in Java DB&lt;/h3&gt;
Java DB uses the Java programming language for its stored procedures.
 Consequently, when you define a stored procedure, you specify which 
Java class to call and where Java DB can find it.&lt;br /&gt;


The following statement creates a stored procedure named &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt;:&lt;br /&gt;


&lt;pre&gt;CREATE PROCEDURE SHOW_SUPPLIERS()
  PARAMETER STYLE JAVA
  LANGUAGE JAVA
  DYNAMIC RESULT SETS 1
  EXTERNAL NAME &#39;com.oracle.tutorial.jdbc.StoredProcedureJavaDBSample.showSuppliers&#39;&lt;/pre&gt;
The following list describes the procedure elements you can specify in the &lt;code&gt;CREATE PROCEDURE&lt;/code&gt; statement:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;PARAMETER STYLE JAVA&lt;/code&gt;: Specifies that the stored 
procedure uses a parameter-passing convention that conforms to the Java 
language and the SQL routines specification (currently, &lt;code&gt;JAVA&lt;/code&gt; is the only option&lt;/li&gt;
&lt;li&gt;&lt;code&gt;LANGUAGE JAVA&lt;/code&gt;: Specifies the programming language of the stored procedure (currently, &lt;code&gt;JAVA&lt;/code&gt; is the only option)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;DYNAMIC RESULT SETS 1&lt;/code&gt;: Specifies the maximum number of result sets retrieved; in this case, it is 1&lt;/li&gt;
&lt;li&gt;&lt;code&gt;EXTERNAL NAME &#39;com.oracle.tutorial.jdbc.StoredProcedureJavaDBSample.showSuppliers&#39;&lt;/code&gt; specifies the fully qualified Java method that this stored procedure calls&lt;/li&gt;
&lt;/ul&gt;
The stored procedure &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt; does not have any 
parameters; see the MySQL documentation for information about how to 
define procedures with parameters (within the parentheses after the 
procedure&#39;s name).&lt;br /&gt;


To add the JAR file that contains the class that the stored procedure
 calls to the database, call the following built-in procedures:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;sqlj.install_jar&lt;/code&gt;: Adds a JAR file to a database.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sqlj.replace_jar&lt;/code&gt;: Replaces a JAR file that already exists in a database.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;syscs_util.syscs_set_database_property&lt;/code&gt;: Sets a database property; use this procedure to set the property &lt;code&gt;derby.database.classpath&lt;/code&gt; to add the JAR file (added to the database by &lt;code&gt;sqlj.install_jar&lt;/code&gt;) to the database&#39;s class path.&lt;/li&gt;
&lt;/ul&gt;
To call a stored procedure, use the &lt;code&gt;CALL&lt;/code&gt; statement:&lt;br /&gt;


&lt;pre&gt;CALL SHOW_SUPPLIERS;&lt;/pre&gt;
&lt;h3&gt;
Overview of Creating Stored Procedures in MySQL&lt;/h3&gt;
MySQL uses a SQL-based syntax for its stored procedures. The following SQL script creates a stored procedure named &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt; that returns the name of the supplier for each type of coffee in the table &lt;code&gt;COFFEES&lt;/code&gt;:&lt;br /&gt;


&lt;pre&gt;SELECT &#39;Dropping procedure SHOW_SUPPLIERS&#39; AS &#39; &#39;;

drop procedure if exists SHOW_SUPPLIERS;

SELECT &#39;Changing delimiter to pipe&#39; AS &#39; &#39;;

delimiter |

SELECT &#39;Creating procedure SHOW_SUPPLIERS&#39; AS &#39; &#39;|

create procedure SHOW_SUPPLIERS()
  begin
    select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME
    from SUPPLIERS, COFFEES
    where SUPPLIERS.SUP_ID = COFFEES.SUP_ID
    order by SUP_NAME;
  end|

delimiter ;&lt;/pre&gt;
The &lt;code&gt;drop procedure&lt;/code&gt; statement deletes that procedure &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt; if it exists. The statement &lt;code&gt;delimiter |&lt;/code&gt; changes the character that separates statements from the semicolon (&lt;code&gt;;&lt;/code&gt;) to the pipe (&lt;code&gt;|&lt;/code&gt;).
 In MySQL, statements in a stored procedure are separated by semicolons.
 However, a different delimiter is required to end the &lt;code&gt;create procedure&lt;/code&gt; statement. This example uses the pipe (&lt;code&gt;|&lt;/code&gt;) character; you can use an other characters (or more than one character).&lt;br /&gt;


The &lt;code&gt;create procedure&lt;/code&gt; statement consists of the name of 
the procedure, a comma-separated list of parameters in parentheses, and 
SQL statements within the &lt;code&gt;begin&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; keywords. The stored procedure &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt; does not have any parameters; see the MySQL documentation for information about how to define procedures with parameters.&lt;br /&gt;


To call a stored procedure, use the &lt;code&gt;CALL&lt;/code&gt; statement:&lt;br /&gt;


&lt;pre&gt;CALL SHOW_SUPPLIERS();&lt;/pre&gt;
&lt;h3&gt;
Creating Stored Procedures in Java DB&lt;/h3&gt;
Creating and using a stored procedure in Java DB involves the following steps:&lt;br /&gt;


&lt;ol&gt;
&lt;li&gt;Create a public static Java method in a Java class; this method performs the required task of the stored procedure.&lt;/li&gt;
&lt;li&gt;Package the Java class in a jar file.&lt;/li&gt;
&lt;li&gt;Create the stored procedure; this stored procedure calls the Java method you created.&lt;/li&gt;
&lt;li&gt;Add the JAR file to the database.&lt;/li&gt;
&lt;li&gt;Call the stored procedure with the &lt;code&gt;CALL&lt;/code&gt; SQL statement.&lt;/li&gt;
&lt;/ol&gt;
The class &lt;code&gt;StoredProcedureJavaDBSample&lt;/code&gt; creates a stored procedure named &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt; that selects the names of all the suppliers from the table &lt;code&gt;SUPPLIERS&lt;/code&gt; that supply coffee listed in the &lt;code&gt;COFFEES&lt;/code&gt; table. When this class calls &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt;, it outputs the following:&lt;br /&gt;


&lt;pre&gt;Acme, Inc.: Colombian_Decaf
Acme, Inc.: Colombian
Superior Coffee: French_Roast_Decaf
Superior Coffee: French_Roast
The High Ground: Espresso&lt;/pre&gt;
&lt;h4&gt;
Creating Public Static Java Method&lt;/h4&gt;
The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;StoredProcedureJavaDBSample.showSuppliers&lt;/a&gt;&lt;/code&gt;, contains the SQL statements that the stored procedure &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt; calls:&lt;br /&gt;


&lt;pre&gt;  public static void showSuppliers(ResultSet[] rs) throws SQLException {
    Connection con = DriverManager.getConnection(&quot;jdbc:default:connection&quot;);
    Statement stmt = null;

    String query =
      &quot;select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME &quot; + &quot;from SUPPLIERS, COFFEES &quot; +
      &quot;where SUPPLIERS.SUP_ID = COFFEES.SUP_ID &quot; + &quot;order by SUP_NAME&quot;;

    stmt = con.createStatement();
    rs[0] = stmt.executeQuery(query);

  }&lt;/pre&gt;
The &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt; stored procedure takes no arguments. 
You can specify arguments in a stored procedure by defining them in the 
method signature of your public static Java method. Note that the method
 &lt;code&gt;showSuppliers&lt;/code&gt; contains a parameter of type &lt;code&gt;ResultSet[]&lt;/code&gt;. If your stored procedure returns any number of &lt;code&gt;ResultSet&lt;/code&gt; objects, specify one parameter of type &lt;code&gt;ResultSet[]&lt;/code&gt; in your Java method. In addition, ensure that this Java method is public and static.&lt;br /&gt;


Retrieve the &lt;code&gt;Connection&lt;/code&gt; object from the URL &lt;code&gt;jdbc:default:connection&lt;/code&gt;. This is a convention in Java DB to indicate that the stored procedure will use the currently existing &lt;code&gt;Connection&lt;/code&gt; object.&lt;br /&gt;


Note that the &lt;code&gt;Statement&lt;/code&gt; object is not closed in this method. Do not close any &lt;code&gt;Statement&lt;/code&gt; objects in the Java method of your stored procedure; if you do so, the &lt;code&gt;ResultSet&lt;/code&gt; object will not exist when you issue the &lt;code&gt;CALL&lt;/code&gt; statement when you call your stored procedure.&lt;br /&gt;




&lt;h4&gt;
Creating Stored Procedure and Specify Commands to Add JAR File to Database&lt;/h4&gt;
Because &lt;code&gt;StoredProcedureJavaDBSample&lt;/code&gt; contains all the 
steps to create and call a stored procedure, these steps are performed 
before packaging the Java class file in a JAR file.&lt;br /&gt;


The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;StoredProcedureJavaDBSample.showSuppliers&lt;/a&gt;&lt;/code&gt;, creates the stored procedure and specifies the commands to add the jar file to the database:&lt;br /&gt;


&lt;pre&gt;  public void createProcedure(Connection con, String jarPathName) throws SQLException {

    Statement stmt = null;
    Statement stmtDrop = null;
    CallableStatement cs2 = null;
    CallableStatement cs2a = null;
    CallableStatement cs3 = null;

    String queryDrop = &quot;DROP PROCEDURE SHOW_SUPPLIERS&quot;;
    String query = &quot;CREATE PROCEDURE SHOW_SUPPLIERS(DBNAME VARCHAR(128)) &quot; +
      &quot;PARAMETER STYLE JAVA &quot; +
      &quot;LANGUAGE JAVA &quot; +
      &quot;DYNAMIC RESULT SETS 1 &quot; +
      &quot;EXTERNAL NAME &#39;com.oracle.tutorial.jdbc.StoredProcedureJavaDBSample.showSuppliers&#39;&quot;;

    String query2 = &quot;CALL sqlj.install_jar(&#39;&quot; + jarPathName + &quot;&#39;,&#39;&quot; + dbName + &quot;.JDBCTutorial&#39;,0)&quot;;
    String query2a = &quot;CALL sqlj.replace_jar(&#39;&quot; + jarPathName + &quot;&#39;,&#39;&quot; + dbName + &quot;.JDBCTutorial&#39;)&quot;;
    String query3 = &quot;CALL syscs_util.syscs_set_database_property(&#39;derby.database.classpath&#39;,&#39;&quot; + dbName + &quot;.JDBCTutorial&#39;)&quot;;

    try {
      stmtDrop = con.createStatement();
      stmtDrop.execute(queryDrop);
    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      stmtDrop.close();
    }
    try {
      stmt = con.createStatement();
      stmt.execute(query);
    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      stmt.close();
    }
    try {
      cs2 = con.prepareCall(query2);
      cs2.execute();
    } catch (SQLException e2) {
      JDBCTutorialUtilities.printSQLException(e2);
    } finally {
      cs2.close();
      try {
        cs2a = con.prepareCall(query2a);
        cs2a.execute();
      } catch (SQLException e2a) {
        JDBCTutorialUtilities.printSQLException(e2a);
      } finally {
        cs2a.close();
      }
    }
    try {
      cs3 = con.prepareCall(query3);
      cs3.execute();
    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      cs3.close();
    }
  }&lt;/pre&gt;
This &lt;code&gt;CREATE PROCEDURE&lt;/code&gt; statement creates the stored procedure &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt;:&lt;br /&gt;


&lt;pre&gt;CREATE PROCEDURE SHOW_SUPPLIERS()
  PARAMETER STYLE JAVA
  LANGUAGE JAVA
  DYNAMIC RESULT SETS 1
  EXTERNAL NAME &#39;com.oracle.tutorial.jdbc.StoredProcedureJavaDBSample.showSuppliers&#39;&lt;/pre&gt;
The &lt;code&gt;install_jar&lt;/code&gt; procedure in the &lt;code&gt;SQL&lt;/code&gt; schema
 adds a JAR file to the database. The first argument of this procedure 
is the full path name of the JAR file on the computer from which this 
procedure is run. The second argument is an identifier that Java DB uses
 to refer to the JAR file. The &lt;code&gt;replace_jar&lt;/code&gt; procedure replaces a JAR file already in the database.&lt;br /&gt;


The system procedure &lt;code&gt;SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY&lt;/code&gt; sets or deletes the value of a property of the database on the current connection. This method sets the property &lt;code&gt;derby.database.classpath&lt;/code&gt; to the identifier specified in the &lt;code&gt;install_jar&lt;/code&gt; file. Java DB first looks in your Java class path for a class, then it looks in &lt;code&gt;derby.database.classpath&lt;/code&gt;.

&lt;br /&gt;
&lt;strong&gt;Note&lt;/strong&gt;: Alternatively, you can specify the location of your JAR file in your &lt;code&gt;CLASSPATH&lt;/code&gt; environment variable. Java DB first looks in your &lt;code&gt;CLASSPATH&lt;/code&gt; for any required classes before looking in the database.&lt;br /&gt;




&lt;h4&gt;
Specify Commands to Call Stored Procedure&lt;/h4&gt;
The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;StoredProcedureJavaDBSample.runStoredProcedure&lt;/a&gt;&lt;/code&gt;, calls the stored procedure:&lt;br /&gt;


&lt;pre&gt;  public void runStoredProcedure(Connection con) throws SQLException {
    CallableStatement cs = null;

    try {
      cs = con.prepareCall(&quot;{call SHOW_SUPPLIERS( &#39;&quot; + this.dbName + &quot;&#39;)}&quot;);
      cs.execute();
      ResultSet rs = cs.getResultSet();
      while (rs.next()) {
        String supplier = rs.getString(&quot;SUP_NAME&quot;);
        String coffee = rs.getString(&quot;COF_NAME&quot;);
        System.out.println(supplier + &quot;: &quot; + coffee);
      }
    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      cs.close();
    }
  }&lt;/pre&gt;
The interface &lt;code&gt;CallableStatement&lt;/code&gt; extends &lt;code&gt;PreparedStatement&lt;/code&gt;. It is used to call stored procedures.&lt;br /&gt;


&lt;strong&gt;Note&lt;/strong&gt;: As with &lt;code&gt;Statement&lt;/code&gt; objects, to call the stored procedure, you can call &lt;code&gt;execute&lt;/code&gt;, &lt;code&gt;executeQuery&lt;/code&gt;, or &lt;code&gt;executeUpdate&lt;/code&gt; depending on how many &lt;code&gt;ResultSet&lt;/code&gt; objects the procedure returns. However, if you are not sure how many &lt;code&gt;ResultSet&lt;/code&gt; objects the procedure returns, call &lt;code&gt;execute&lt;/code&gt;.&lt;br /&gt;




&lt;h4&gt;
Package Java Class in JAR File&lt;/h4&gt;
The Ant build script &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;build.xml&lt;/a&gt;&lt;/code&gt; contains targets to compile and package the tutorial in a JAR file. At a command prompt, change the current directory to &lt;code&gt;&lt;em&gt;&amp;lt;JDBC tutorial directory&amp;gt;&lt;/em&gt;&lt;/code&gt;. From this directory, run the following command to compile and package the tutorial in a JAR file:&lt;br /&gt;


&lt;code&gt;ant jar&lt;/code&gt;&lt;br /&gt;


The name of the JAR file is &lt;code&gt;&lt;em&gt;&amp;lt;JDBC tutorial directory&amp;gt;&lt;/em&gt;/lib/JDBCTutorial.jar&lt;/code&gt;.&lt;br /&gt;


&lt;strong&gt;Note&lt;/strong&gt;: Ensure that you have modified &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;sampleproperties.xml&lt;/a&gt;&lt;/code&gt; so that the value of the property &lt;code&gt;jar_file&lt;/code&gt; is set to the full path name of &lt;code&gt;JDBCTutorial.jar&lt;/code&gt;.&lt;br /&gt;




&lt;h3&gt;
Creating Stored Procedure in MySQL&lt;/h3&gt;
Creating and using a stored procedure in Java DB involves the following steps:&lt;br /&gt;


&lt;ol&gt;
&lt;li&gt;Create the stored procedure with JDBC API&lt;/li&gt;
&lt;li&gt;Call the stored procedure with the &lt;code&gt;CALL&lt;/code&gt; SQL statement&lt;/li&gt;
&lt;/ol&gt;
The class &lt;code&gt;StoredProcedureMySQLSample&lt;/code&gt; creates a stored procedure named &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt; that selects the names of all the suppliers from the table &lt;code&gt;SUPPLIERS&lt;/code&gt; that supply coffee listed in the &lt;code&gt;COFFEES&lt;/code&gt; table. When this class calls &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt;, it outputs the following:&lt;br /&gt;


&lt;pre&gt;Acme, Inc.: Colombian_Decaf
Acme, Inc.: Colombian
Superior Coffee: French_Roast_Decaf
Superior Coffee: French_Roast
The High Ground: Espresso&lt;/pre&gt;
&lt;h4&gt;
Creating Stored Procedure with JDBC API&lt;/h4&gt;
The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;StoredProcedureMySQLSample&lt;/a&gt;&lt;/code&gt;, creates a stored procedure named &lt;code&gt;SHOW_SUPPLIERS&lt;/code&gt;:&lt;br /&gt;


&lt;pre&gt;  public void createProcedureShowSuppliers() throws SQLException {
    String createProcedure = null;
    createProcedure = &quot;create procedure SHOW_SUPPLIERS() &quot; +
           &quot;begin &quot; +
           &quot;select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME &quot; +
           &quot;from SUPPLIERS, COFFEES &quot; +
           &quot;where SUPPLIERS.SUP_ID = COFFEES.SUP_ID &quot; +
           &quot;order by SUP_NAME; &quot; +
           &quot;end&quot;;
    Statement stmt = null;

    try {
      stmt = con.createStatement();
      stmt.executeUpdate(createProcedure);
    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      stmt.close();
    }
  }&lt;/pre&gt;
This &lt;code&gt;CREATE PROCEDURE&lt;/code&gt; statement creates a stored procedure:&lt;br /&gt;


&lt;pre&gt;create procedure SHOW_SUPPLIERS()
  begin
  select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME
  from SUPPLIERS, COFFEES
  where SUPPLIERS.SUP_ID = COFFEES.SUP_ID
  order by SUP_NAME;
end&lt;/pre&gt;
MySQL uses a SQL-based syntax for its stored procedures. Note that the &lt;code&gt;Connection&lt;/code&gt; object &lt;code&gt;con&lt;/code&gt; must be connected to a specific database.&lt;br /&gt;




&lt;h4&gt;
Calling Stored Procedures&lt;/h4&gt;
The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;StoredProcedureMySQLample.runStoredProcedure&lt;/a&gt;&lt;/code&gt;, calls the stored procedure:&lt;br /&gt;


&lt;pre&gt;  public void runStoredProcedure() throws SQLException {
    CallableStatement cs = null;

    try {
      cs = con.prepareCall(&quot;{call SHOW_SUPPLIERS}&quot;);
      ResultSet rs = cs.executeQuery();

      while (rs.next()) {
        String supplier = rs.getString(&quot;SUP_NAME&quot;);
        String coffee = rs.getString(&quot;COF_NAME&quot;);
        System.out.println(supplier + &quot;: &quot; + coffee);
      }

    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      cs.close();
    }
  }&lt;/pre&gt;
The interface &lt;code&gt;CallableStatement&lt;/code&gt; extends &lt;code&gt;PreparedStatement&lt;/code&gt;. It is used to call stored procedures.&lt;br /&gt;


&lt;strong&gt;Note&lt;/strong&gt;: As with &lt;code&gt;Statement&lt;/code&gt; objects, to call the stored procedure, you can call &lt;code&gt;execute&lt;/code&gt;, &lt;code&gt;executeQuery&lt;/code&gt;, or &lt;code&gt;executeUpdate&lt;/code&gt; depending on how many &lt;code&gt;ResultSet&lt;/code&gt; objects the procedure returns. However, if you are not sure how many &lt;code&gt;ResultSet&lt;/code&gt; objects the procedure returns, call &lt;code&gt;execute&lt;/code&gt;.&lt;br /&gt;



        &lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/2944235015197009014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcusing-stored-procedures.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/2944235015197009014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/2944235015197009014'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcusing-stored-procedures.html' title='JDBC:Using Stored Procedures'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-6108824787622129660</id><published>2011-01-15T12:50:00.001-08:00</published><updated>2011-01-15T12:50:24.293-08:00</updated><title type='text'>JDBC:Using Transactions</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
Using Transactions&lt;/div&gt;
&lt;blockquote&gt;

There are times when you do not want one statement to take effect 
unless another one completes. For example, when the proprietor of The 
Coffee Break updates the amount of coffee sold each week, he will also 
want to update the total amount sold to date. However, he will not want 
to update one without  updating the other; otherwise, the data will be 
inconsistent. The way to be sure that either both actions occur or 
neither action occurs is to use a transaction. A transaction is a set of
 one or more statements that is executed as a unit, so either all of the
 statements are executed, or none of the statements is executed. &lt;br /&gt;


&lt;h3&gt;
Disabling Auto-Commit Mode&lt;/h3&gt;
When a connection is created, it is in auto-commit mode. This means 
that each individual SQL statement is treated as a transaction and is 
automatically committed right after it is executed. (To be more precise,
 the default is for a SQL statement to be committed when it is 
completed, not when it is executed. A statement is completed when all of
 its result sets and update counts have been retrieved. In almost all 
cases, however, a statement is completed, and therefore committed, right
 after it is executed.)&lt;br /&gt;


The way to allow two or more statements to be grouped into a 
transaction is to disable the auto-commit mode. This is demonstrated in 
the following code, where &lt;code&gt;
con&lt;/code&gt; is an active connection:&lt;br /&gt;

&lt;blockquote&gt;
&lt;pre&gt;con.setAutoCommit(false);&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
Committing Transactions&lt;/h3&gt;
After the auto-commit mode is disabled, no SQL statements are committed until you call the method &lt;code&gt;commit&lt;/code&gt; explicitly. All statements executed after the previous call to the method &lt;code&gt;commit&lt;/code&gt; are included in the current transaction and committed together as a unit. The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.updateCoffeeSales&lt;/a&gt;&lt;/code&gt;, in which &lt;code&gt;con&lt;/code&gt; is an active connection, illustrates a transaction:&lt;br /&gt;


&lt;pre&gt;  public void updateCoffeeSales(HashMap&amp;lt;String, Integer&amp;gt; salesForWeek) throws SQLException {

    PreparedStatement updateSales = null;
    PreparedStatement updateTotal = null;

    String updateString = &quot;update &quot; + dbName + &quot;.COFFEES &quot; +
                          &quot;set SALES = ? where COF_NAME = ?&quot;;

    String updateStatement = &quot;update &quot; + dbName + &quot;.COFFEES &quot; +
                             &quot;set TOTAL = TOTAL + ? where COF_NAME = ?&quot;;

    try {
      con.setAutoCommit(false);
      updateSales = con.prepareStatement(updateString);
      updateTotal = con.prepareStatement(updateStatement);

      for (Map.Entry&amp;lt;String, Integer&amp;gt; e : salesForWeek.entrySet()) {
        updateSales.setInt(1, e.getValue().intValue());
        updateSales.setString(2, e.getKey());
        updateSales.executeUpdate();

        updateTotal.setInt(1, e.getValue().intValue());
        updateTotal.setString(2, e.getKey());
        updateTotal.executeUpdate();
        con.commit();
      }
    } catch (SQLException e ) {
      JDBCTutorialUtilities.printSQLException(e);
      if (con != null) {
        try {
          System.err.print(&quot;Transaction is being rolled back&quot;);
          con.rollback();
        } catch(SQLException excep) {
          JDBCTutorialUtilities.printSQLException(excep);
        }
      }
    } finally {
      updateSales.close();
      updateTotal.close();
      con.setAutoCommit(true);
    }
  }&lt;/pre&gt;
In this method, the auto-commit mode is disabled for the connection &lt;code&gt;con&lt;/code&gt;, which means that the two prepared statements &lt;code&gt;updateSales&lt;/code&gt; and &lt;code&gt;updateTotal&lt;/code&gt; are committed together when the method &lt;code&gt;commit&lt;/code&gt; is called. Whenever the &lt;code&gt;commit&lt;/code&gt;
 method is called (either automatically when auto-commit mode is enabled
 or explicitly when it is disabled), all changes resulting from 
statements in the transaction are made permanent. In this case, that 
means that the &lt;code&gt;SALES&lt;/code&gt; and &lt;code&gt;TOTAL&lt;/code&gt; columns for Colombian coffee have been changed to &lt;code&gt;50&lt;/code&gt; (if &lt;code&gt;TOTAL&lt;/code&gt; had been &lt;code&gt;0&lt;/code&gt; previously) and will retain this value until they are changed with another update statement.&lt;br /&gt;


The statement &lt;code&gt;con.setAutoCommit(true);&lt;/code&gt; enables 
auto-commit mode, which means that each statement is once again 
committed automatically when it is completed. Then, you are back to the 
default state where you do not have to call the method &lt;code&gt;commit&lt;/code&gt;
 yourself. It is advisable to disable the auto-commit mode only during 
the transaction mode. This way, you avoid holding database locks for 
multiple statements, which increases the likelihood of conflicts with 
other users.&lt;br /&gt;


&lt;h3&gt;
Using Transactions to Preserve Data Integrity&lt;/h3&gt;
In addition to grouping statements together for execution as a unit, 
transactions can help to preserve the integrity of the data in a table. 
For instance, imagine that an employee was supposed to enter new coffee 
prices in the table &lt;code&gt;COFFEES&lt;/code&gt; but delayed doing it for a few 
days. In the meantime, prices rose, and today the owner is in the 
process of entering the higher prices. The employee finally gets around 
to entering the now outdated prices at the same time that the owner is 
trying to update the table. After inserting the outdated prices, the 
employee realizes that they are no longer valid and calls the &lt;code&gt;Connection&lt;/code&gt; method &lt;code&gt;rollback&lt;/code&gt; to undo their effects. (The method &lt;code&gt;rollback&lt;/code&gt;
 aborts a transaction and restores values to what they were before the 
attempted update.) At the same time, the owner is executing a &lt;code&gt;SELECT&lt;/code&gt;
 statement and printing the new prices. In this situation, it is 
possible that the owner will print a price that had been rolled back to 
its previous value, making the printed price incorrect.&lt;br /&gt;


This kind of situation can be avoided by using transactions, 
providing some level of protection against conflicts that arise when two
 users access data at the same time. &lt;br /&gt;


To avoid conflicts during a transaction, a DBMS uses locks, 
mechanisms for blocking access by others to the data that is being 
accessed by the transaction. (Note that in auto-commit mode, where each 
statement is a transaction, locks are held for only one statement.) 
After a lock is set, it remains in force until the transaction is 
committed or rolled back. For example, a DBMS could lock a row of a 
table until updates to it have been committed. The effect of this lock 
would be to prevent a user from getting a dirty read, that is, reading a
 value before it is made permanent. (Accessing an updated value that has
 not been committed is considered a &lt;em&gt;dirty read&lt;/em&gt; because it is 
possible for that value to be rolled back to its previous value. If you 
read a value that is later rolled back, you will have read an invalid 
value.)&lt;br /&gt;


How locks are set is determined by what is called a transaction 
isolation level, which can range from not supporting transactions at all
 to supporting transactions that enforce very strict access rules.&lt;br /&gt;


One example of a transaction isolation level is &lt;code&gt;TRANSACTION_READ_COMMITTED&lt;/code&gt;,
 which will not allow a value to be accessed until after it has been 
committed. In other words, if the transaction isolation level is set to &lt;code&gt;TRANSACTION_READ_COMMITTED&lt;/code&gt;, the DBMS does not allow dirty reads to occur. The interface &lt;code&gt;Connection&lt;/code&gt; includes five values that represent the transaction isolation levels you can use in JDBC:&lt;br /&gt;


&lt;table border=&quot;1&quot; summary=&quot;Transaction isolation levels&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;Isolation Level&lt;/th&gt;
  &lt;th&gt;Transactions&lt;/th&gt;
  &lt;th&gt;Dirty Reads&lt;/th&gt;
  &lt;th&gt;Non-Repeatable Reads&lt;/th&gt;
  &lt;th&gt;Phantom Reads&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;TRANSACTION_NONE&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Not supported&lt;/td&gt;
  &lt;td&gt;&lt;em&gt;Not applicable&lt;/em&gt;&lt;/td&gt;
  &lt;td&gt;&lt;em&gt;Not applicable&lt;/em&gt;&lt;/td&gt;
  &lt;td&gt;&lt;em&gt;Not applicable&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;TRANSACTION_READ_COMMITTED&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Supported&lt;/td&gt;
  &lt;td&gt;Prevented&lt;/td&gt;
  &lt;td&gt;Allowed&lt;/td&gt;
  &lt;td&gt;Allowed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;TRANSACTION_READ_UNCOMMITTED&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Supported&lt;/td&gt;
  &lt;td&gt;Allowed&lt;/td&gt;
  &lt;td&gt;Allowed&lt;/td&gt;
  &lt;td&gt;Allowed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;TRANSACTION_REPEATABLE_READ&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Supported&lt;/td&gt;
  &lt;td&gt;Prevented&lt;/td&gt;
  &lt;td&gt;Prevented&lt;/td&gt;
  &lt;td&gt;Allowed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;TRANSACTION_SERIALIZABLE&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Supported&lt;/td&gt;
  &lt;td&gt;Prevented&lt;/td&gt;
  &lt;td&gt;Prevented&lt;/td&gt;
  &lt;td&gt;Prevented&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
A &lt;em&gt;non-repeatable read&lt;/em&gt; occurs when transaction A retrieves a 
row, transaction B subsequently updates the row, and transaction A later
 retrieves the same row again. Transaction A retrieves the same row 
twice but sees different data.&lt;br /&gt;


A &lt;em&gt;phantom read&lt;/em&gt; occurs when transaction A retrieves a set of 
rows satisfying a given condition, transaction B subsequently inserts or
 updates a row such that the row now meets the condition in transaction 
A, and transaction A later repeats the conditional retrieval. 
Transaction A now sees an additional row. This row is referred to as a 
phantom.&lt;br /&gt;


Usually, you do not need to do anything about the transaction 
isolation level; you can just use the default one for your DBMS. The 
default transaction isolation level depends on your DBMS. For example, 
for Java DB, it is &lt;code&gt;TRANSACTION_READ_COMMITTED&lt;/code&gt;. JDBC allows you to find out what transaction isolation level your DBMS is set to (using the &lt;code&gt;Connection&lt;/code&gt; method &lt;code&gt;getTransactionIsolation&lt;/code&gt;) and also allows you to set it to another level (using the &lt;code&gt;Connection&lt;/code&gt; method &lt;code&gt;setTransactionIsolation&lt;/code&gt;).&lt;br /&gt;


&lt;strong&gt;Note&lt;/strong&gt;: A JDBC driver might not support all 
transaction isolation levels. If a driver does not support the isolation
 level specified in an invocation of &lt;code&gt;setTransactionIsolation&lt;/code&gt;,
 the driver can substitute a higher, more restrictive transaction 
isolation level. If a driver cannot substitute a higher transaction 
level, it throws a &lt;code&gt;SQLException&lt;/code&gt;. Use the method &lt;code&gt;DatabaseMetaData.supportsTransactionIsolationLevel&lt;/code&gt; to determine whether or not the driver supports a given level.&lt;br /&gt;


&lt;h3&gt;
Setting and Rolling Back to Savepoints&lt;/h3&gt;
The method &lt;code&gt;Connection.setSavepoint&lt;/code&gt;, sets a &lt;code&gt;Savepoint&lt;/code&gt; object within the current transaction. The &lt;code&gt;Connection.rollback&lt;/code&gt; method is overloaded to take a &lt;code&gt;Savepoint&lt;/code&gt; argument.&lt;br /&gt;


The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.modifyPricesByPercentage&lt;/a&gt;&lt;/code&gt;, raises the price of a particular coffee by a percentage, &lt;code&gt;priceModifier&lt;/code&gt;. However, if the new price is greater than a specified price, &lt;code&gt;maximumPrice&lt;/code&gt;, then the price is reverted to the original price:&lt;br /&gt;


&lt;pre&gt;   public void modifyPricesByPercentage(String coffeeName, float priceModifier,
                                       float maximumPrice) throws SQLException {
    con.setAutoCommit(false);

    Statement getPrice = null;
    Statement updatePrice = null;
    ResultSet rs = null;
    String query =
      &quot;SELECT COF_NAME, PRICE FROM COFFEES &quot; + &quot;WHERE COF_NAME = &#39;&quot; +
      coffeeName + &quot;&#39;&quot;;

    try {
      Savepoint save1 = con.setSavepoint();
      getPrice =
          con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
      updatePrice = con.createStatement();

      if (!getPrice.execute(query)) {
        System.out.println(&quot;Could not find entry for coffee named &quot; +
                           coffeeName);
      } else {
        rs = getPrice.getResultSet();
        rs.first();
        float oldPrice = rs.getFloat(&quot;PRICE&quot;);
        float newPrice = oldPrice + (oldPrice * priceModifier);
        System.out.println(&quot;Old price of &quot; + coffeeName + &quot; is &quot; + oldPrice);
        System.out.println(&quot;New price of &quot; + coffeeName + &quot; is &quot; + newPrice);
        System.out.println(&quot;Performing update...&quot;);
        updatePrice.executeUpdate(&quot;UPDATE COFFEES SET PRICE = &quot; + newPrice +
                                  &quot; WHERE COF_NAME = &#39;&quot; + coffeeName + &quot;&#39;&quot;);
        System.out.println(&quot;\nCOFFEES table after update:&quot;);
        CoffeesTable.viewTable(con);
        if (newPrice &amp;gt; maximumPrice) {
          System.out.println(&quot;\nThe new price, &quot; + newPrice +
                             &quot;, is greater than the maximum &quot; + &quot;price, &quot; +
                             maximumPrice +
                             &quot;. Rolling back the transaction...&quot;);
          con.rollback(save1);
          System.out.println(&quot;\nCOFFEES table after rollback:&quot;);
          CoffeesTable.viewTable(con);
        }
        con.commit();
      }
    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      getPrice.close();
      updatePrice.close();
      con.setAutoCommit(true);
    }
  }&lt;/pre&gt;
The following statement specifies that the cursor of the &lt;code&gt;ResultSet&lt;/code&gt; object generated from the &lt;code&gt;getPrice&lt;/code&gt; query is closed when the &lt;code&gt;commit&lt;/code&gt; method is called. Note that if your DBMs does not support &lt;code&gt;ResultSet.CLOSE_CURSORS_AT_COMMIT&lt;/code&gt;, then this constant is ignored:&lt;br /&gt;


&lt;pre&gt;      getPrice = con.prepareStatement(query, ResultSet.CLOSE_CURSORS_AT_COMMIT);&lt;/pre&gt;
The method begins by creating a &lt;code&gt;Savepoint&lt;/code&gt; with the following statement:&lt;br /&gt;


&lt;pre&gt;        Savepoint save1 = con.setSavepoint();&lt;/pre&gt;
The method checks if the new price is greater than the &lt;code&gt;maximumPrice&lt;/code&gt; value. If so, the method rolls back the transaction with the following statement:&lt;br /&gt;


&lt;pre&gt;          con.rollback(save1);&lt;/pre&gt;
Consequently, when the method commits the transaction by calling the &lt;code&gt;Connection.commit&lt;/code&gt; method, it will not commit any rows whose associated &lt;code&gt;Savepoint&lt;/code&gt; has been rolled back; it will commit all the other updated rows.&lt;br /&gt;


&lt;h3&gt;
Releasing Savepoints&lt;/h3&gt;
The method &lt;code&gt;Connection.releaseSavepoint&lt;/code&gt; takes a &lt;code&gt;Savepoint&lt;/code&gt; object as a parameter and removes it from the current transaction.&lt;br /&gt;


After a savepoint has been released, attempting to reference it in a rollback operation causes a &lt;code&gt;SQLException&lt;/code&gt;
 to be thrown. Any savepoints that have been created in a transaction 
are automatically released and become invalid when the transaction is 
committed, or when the entire transaction is rolled back. Rolling a 
transaction back to a savepoint automatically releases and makes invalid
 any other savepoints that were created after the savepoint in question.&lt;br /&gt;


&lt;h3&gt;
When to Call the Method rollback&lt;/h3&gt;
As mentioned earlier, calling the method &lt;code&gt;rollback&lt;/code&gt; 
terminates a transaction and returns any values that were modified to 
their previous values. If you are trying to execute one or more 
statements in a transaction and get a &lt;code&gt;SQLException&lt;/code&gt;, call the method &lt;code&gt;rollback&lt;/code&gt;
 to end the transaction and start the transaction all over again. That 
is the only way to know what has been committed and what has not been 
committed. Catching a &lt;code&gt;SQLException&lt;/code&gt; tells you that something
 is wrong, but it does not tell you what was or was not committed. 
Because you cannot count on the fact that nothing was committed, calling
 the method &lt;code&gt;rollback&lt;/code&gt; is the only way to be certain.&lt;br /&gt;


The method &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.updateCoffeeSales&lt;/a&gt;&lt;/code&gt; demonstrates a transaction and includes a &lt;code&gt;catch&lt;/code&gt; block that invokes the method &lt;code&gt;rollback&lt;/code&gt;. If the application continues and uses the results of the transaction, this call to the &lt;code&gt;rollback&lt;/code&gt; method in the &lt;code&gt;catch&lt;/code&gt; block prevents the use of possibly incorrect data.&lt;br /&gt;
        &lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/6108824787622129660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcusing-transactions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/6108824787622129660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/6108824787622129660'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcusing-transactions.html' title='JDBC:Using Transactions'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-8354608725440166701</id><published>2011-01-15T12:49:00.001-08:00</published><updated>2011-01-15T12:49:32.441-08:00</updated><title type='text'>JDBC:Using Prepared Statements</title><content type='html'>&lt;br /&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
Using Prepared Statements&lt;/div&gt;
&lt;blockquote&gt;

Sometimes it is more convenient to use a &lt;code&gt;PreparedStatement&lt;/code&gt; object for sending SQL statements to the database. This special type of statement is derived from the more general class, &lt;code&gt;Statement&lt;/code&gt;, that you already know.&lt;br /&gt;


If you want to execute a &lt;code&gt;Statement&lt;/code&gt; object many times, it usually reduces execution time to use a &lt;code&gt;PreparedStatement&lt;/code&gt; object instead.&lt;br /&gt;


The main feature of a &lt;code&gt;PreparedStatement&lt;/code&gt; object is that, unlike a &lt;code&gt;Statement&lt;/code&gt;
 object, it is given a SQL statement when it is created. The advantage 
to this is that in most cases, this SQL statement is sent to the DBMS 
right away, where it is compiled. As a result, the &lt;code&gt;PreparedStatement&lt;/code&gt; object contains not just a SQL statement, but a SQL statement that has been precompiled. This means that when the &lt;code&gt;
PreparedStatement&lt;/code&gt; is executed, the DBMS can just run the &lt;code&gt;PreparedStatement&lt;/code&gt; SQL statement without having to compile it first. &lt;br /&gt;


Although &lt;code&gt;PreparedStatement&lt;/code&gt; objects can be used for SQL 
statements with no parameters, you probably use them most often for SQL 
statements that take parameters. The advantage of using SQL statements 
that take parameters is that you can use the same statement and supply 
it with different values each time you execute it. Examples of this are 
in the following sections.&lt;br /&gt;


The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.updateCoffeeSales&lt;/a&gt;&lt;/code&gt;, stores the number of pounds of coffee sold in the current week in the &lt;code&gt;SALES&lt;/code&gt; column for each type of coffee, and updates the total number of pounds of coffee sold in the &lt;code&gt;TOTAL&lt;/code&gt; column for each type of coffee:&lt;br /&gt;


&lt;pre&gt;  public void updateCoffeeSales(HashMap&amp;lt;String, Integer&amp;gt; salesForWeek) throws SQLException {

    PreparedStatement updateSales = null;
    PreparedStatement updateTotal = null;

    String updateString = &quot;update &quot; + dbName + &quot;.COFFEES &quot; +
                          &quot;set SALES = ? where COF_NAME = ?&quot;;

    String updateStatement = &quot;update &quot; + dbName + &quot;.COFFEES &quot; +
                             &quot;set TOTAL = TOTAL + ? where COF_NAME = ?&quot;;

    try {
      con.setAutoCommit(false);
      updateSales = con.prepareStatement(updateString);
      updateTotal = con.prepareStatement(updateStatement);

      for (Map.Entry&amp;lt;String, Integer&amp;gt; e : salesForWeek.entrySet()) {
        updateSales.setInt(1, e.getValue().intValue());
        updateSales.setString(2, e.getKey());
        updateSales.executeUpdate();

        updateTotal.setInt(1, e.getValue().intValue());
        updateTotal.setString(2, e.getKey());
        updateTotal.executeUpdate();
        con.commit();
      }
    } catch (SQLException e ) {
      JDBCTutorialUtilities.printSQLException(e);
      if (con != null) {
        try {
          System.err.print(&quot;Transaction is being rolled back&quot;);
          con.rollback();
        } catch(SQLException excep) {
          JDBCTutorialUtilities.printSQLException(excep);
        }
      }
    } finally {
      updateSales.close();
      updateTotal.close();
      con.setAutoCommit(true);
    }
  }&lt;/pre&gt;
&lt;h3&gt;
Creating a PreparedStatement Object&lt;/h3&gt;
The following creates a &lt;code&gt;PreparedStatement&lt;/code&gt; object that takes two input parameters:&lt;br /&gt;


&lt;pre&gt;    String updateString = &quot;update &quot; + dbName + &quot;.COFFEES &quot; +
                          &quot;set SALES = ? where COF_NAME = ?&quot;;
      updateSales = con.prepareStatement(updateString);&lt;/pre&gt;
&lt;h3&gt;
Supplying Values for PreparedStatement Parameters&lt;/h3&gt;
You must supply values in place of the question mark placeholders (if there are any) before you can execute a &lt;code&gt;PreparedStatement&lt;/code&gt; object. Do this by calling one of the setter methods defined in the &lt;code&gt;PreparedStatement&lt;/code&gt; class. The following statements supply the two question mark placeholders in the &lt;code&gt;PreparedStatement&lt;/code&gt; named &lt;code&gt;updateSales&lt;/code&gt;:&lt;br /&gt;


&lt;pre&gt;        updateSales.setInt(1, e.getValue().intValue());
        updateSales.setString(2, e.getKey());&lt;/pre&gt;
The first argument for each of these setter methods specifies the question mark placeholder. In this example, &lt;code&gt;setInt&lt;/code&gt; specifies the first placeholder and &lt;code&gt;setString&lt;/code&gt; specifies the second placeholder.&lt;br /&gt;


After a parameter has been set with a value, it retains that value until it is reset to another value, or the method &lt;code&gt;clearParameters&lt;/code&gt; is called. Using the &lt;code&gt;PreparedStatement&lt;/code&gt; object &lt;code&gt;updateSales&lt;/code&gt;,
 the following code fragment illustrates reusing a prepared statement 
after resetting the value of one of its parameters and leaving the other
 one the same:

&lt;br /&gt;
&lt;pre&gt;    &lt;strong&gt;// changes SALES column of French Roast row to 100&lt;/strong&gt;

    updateSales.setInt(1, 100);
    updateSales.setString(2, &quot;French_Roast&quot;);
    updateSales.executeUpdate();

    &lt;strong&gt;// changes SALES column of Espresso row to 100 (the first
    // parameter stayed 100, and the second parameter was reset
    // to &quot;Espresso&quot;)&lt;/strong&gt;

    updateSales.setString(2, &quot;Espresso&quot;);
    updateSales.executeUpdate();&lt;/pre&gt;
&lt;h4&gt;
Using Loops to Set Values&lt;/h4&gt;
You can often make coding easier by using a &lt;code&gt;for&lt;/code&gt; loop or a &lt;code&gt;while&lt;/code&gt; loop to set values for input parameters.&lt;br /&gt;


The &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.updateCoffeeSales&lt;/a&gt;&lt;/code&gt; method uses a for-each loop to repeatedly set values in the &lt;code&gt;PreparedStatement&lt;/code&gt; objects &lt;code&gt;updateSales&lt;/code&gt; and &lt;code&gt;updateTotal&lt;/code&gt;:&lt;br /&gt;


&lt;pre&gt;      for (Map.Entry&amp;lt;String, Integer&amp;gt; e : salesForWeek.entrySet()) {

        updateSales.setInt(1, e.getValue().intValue());
        updateSales.setString(2, e.getKey());

        // ...

      }&lt;/pre&gt;
The method &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.updateCoffeeSales&lt;/a&gt;&lt;/code&gt; takes one argument, &lt;code&gt;HashMap&lt;/code&gt;. Each element in the &lt;code&gt;HashMap&lt;/code&gt;
 argument contains the name of one type of coffee and the number of 
pounds of that type of coffee sold during the current week. The for-each
 loop iterates through each element of the &lt;code&gt;HashMap&lt;/code&gt; argument and sets the appropriate question mark placeholders in &lt;code&gt;updateSales&lt;/code&gt; and &lt;code&gt;updateTotal&lt;/code&gt;.&lt;br /&gt;




&lt;h3&gt;
Executing PreparedStatement Objects&lt;/h3&gt;
As with &lt;code&gt;Statement&lt;/code&gt; objects, to execute a &lt;code&gt;PreparedStatement&lt;/code&gt; object, call an execute statement: &lt;code&gt;executeQuery&lt;/code&gt; if the query returns only one &lt;code&gt;ResultSet&lt;/code&gt; (such as a &lt;code&gt;SELECT&lt;/code&gt; SQL statement), &lt;code&gt;executeUpdate&lt;/code&gt; if the query does not return a &lt;code&gt;ResultSet&lt;/code&gt; (such as an &lt;code&gt;UPDATE&lt;/code&gt; SQL statement), or &lt;code&gt;execute&lt;/code&gt; if the query might return more than one &lt;code&gt;ResultSet&lt;/code&gt; object. Both &lt;code&gt;PreparedStatement&lt;/code&gt; objects in &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.updateCoffeeSales&lt;/a&gt;&lt;/code&gt; contain &lt;code&gt;UPDATE&lt;/code&gt; SQL statements, so both are executed by calling &lt;code&gt;executeUpdate&lt;/code&gt;:&lt;br /&gt;


&lt;pre&gt;        updateSales.setInt(1, e.getValue().intValue());
        updateSales.setString(2, e.getKey());
        &lt;strong&gt;updateSales.executeUpdate();&lt;/strong&gt;

        updateTotal.setInt(1, e.getValue().intValue());
        updateTotal.setString(2, e.getKey());
        &lt;code&gt;updateTotal.executeUpdate();&lt;/code&gt;
        con.commit();&lt;/pre&gt;
No arguments are supplied to &lt;code&gt;executeUpdate&lt;/code&gt; when they are used to execute &lt;code&gt;updateSales&lt;/code&gt; and &lt;code&gt;updateTotals&lt;/code&gt;; both &lt;code&gt;PreparedStatement&lt;/code&gt; objects already contain the SQL statement to be executed.&lt;br /&gt;


&lt;strong&gt;Note&lt;/strong&gt;: At the beginning of &lt;code&gt;CoffeesTable.updateCoffeeSales&lt;/code&gt;, the auto-commit mode is set to false:&lt;br /&gt;


&lt;pre&gt;      con.setAutoCommit(false);&lt;/pre&gt;
Consequently, no SQL statements are committed until the method &lt;code&gt;commit&lt;/code&gt; is called. For more information about the auto-commit mode, see #usemacro AUTOMATICLINK (
    LINKFILE transactions.html
)
.&lt;br /&gt;




&lt;h4&gt;
Return Values for the executeUpdate Method&lt;/h4&gt;
Whereas &lt;code&gt;executeQuery&lt;/code&gt; returns a &lt;code&gt;ResultSet&lt;/code&gt; object containing the results of the query sent to the DBMS, the return value for &lt;code&gt;executeUpdate&lt;/code&gt; is an &lt;code&gt;int&lt;/code&gt; value that indicates how many rows of a table were updated. For instance, the following code shows the return value of &lt;code&gt;executeUpdate&lt;/code&gt; being assigned to the variable &lt;code&gt;n&lt;/code&gt;:

&lt;br /&gt;
&lt;pre&gt;    updateSales.setInt(1, 50);
    updateSales.setString(2, &quot;Espresso&quot;);
    int n = updateSales.executeUpdate();
    &lt;strong&gt;// n = 1 because one row had a change in it&lt;/strong&gt;&lt;/pre&gt;
The table &lt;code&gt;COFFEES&lt;/code&gt; is updated; the value 50 replaces the value in the column &lt;code&gt;SALES&lt;/code&gt; in the row for &lt;code&gt;Espresso&lt;/code&gt;. That update affects one row in the table, so &lt;code&gt;n&lt;/code&gt; is equal to 1.&lt;br /&gt;


When the method &lt;code&gt;executeUpdate&lt;/code&gt; is used to execute a DDL (data definition language) statement, such as in creating a table, it returns the &lt;code&gt;int&lt;/code&gt; value of 0. Consequently, in the following code fragment, which executes the DDL statement used to create the table &lt;code&gt;COFFEES&lt;/code&gt;, &lt;code&gt;n&lt;/code&gt; is assigned a value of 0:&lt;br /&gt;


&lt;pre&gt;        int n = executeUpdate(createTableCoffees); &lt;strong&gt;// n = 0&lt;/strong&gt;&lt;/pre&gt;
Note that when the return value for &lt;code&gt;executeUpdate&lt;/code&gt; is 0, it can mean one of two things:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;The statement executed was an update statement that affected zero rows.&lt;/li&gt;
&lt;li&gt;The statement executed was a DDL statement.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/8354608725440166701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcusing-prepared-statements.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/8354608725440166701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/8354608725440166701'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcusing-prepared-statements.html' title='JDBC:Using Prepared Statements'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-2247953689421189197</id><published>2011-01-15T12:48:00.002-08:00</published><updated>2011-01-15T12:48:52.670-08:00</updated><title type='text'>JDBC:Using Joins</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
Using Joins&lt;/div&gt;
&lt;blockquote&gt;

Sometimes you need to use two or more tables to get the data you 
want. For example, suppose the proprietor of The Coffee Break wants a 
list of the coffees he buys from Acme, Inc. This involves information in
 the &lt;code&gt;COFFEES&lt;/code&gt; table as well as the yet-to-be-created &lt;code&gt;SUPPLIERS&lt;/code&gt;
 table. This is a case where a join is needed. A join is a database 
operation that relates two or more tables by means of values that they 
share in common. In our example database, the tables &lt;code&gt;COFFEES&lt;/code&gt; and &lt;code&gt;SUPPLIERS&lt;/code&gt; both have the column &lt;code&gt;SUP_ID&lt;/code&gt;, which can be used to join them.&lt;br /&gt;


The names of the suppliers are in the table &lt;code&gt; SUPPLIERS&lt;/code&gt;, and the names of the coffees are in the table &lt;code&gt; COFFEES&lt;/code&gt;. Because both tables have the column &lt;code&gt;SUP_ID&lt;/code&gt;, this column can be used in a join. You need some way to distinguish to which &lt;code&gt;SUP_ID&lt;/code&gt; column you are referring. This is done by preceding the column name with the table name, as in &quot;&lt;code&gt;COFFEES.SUP_ID&lt;/code&gt;&quot; to indicate that you mean the column &lt;code&gt;SUP_ID&lt;/code&gt; in the table &lt;code&gt;COFFEES&lt;/code&gt;. The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;JoinSample.getCoffeesBoughtBySupplier&lt;/a&gt;&lt;/code&gt;, selects the coffees bought from a particular supplier:&lt;br /&gt;


&lt;pre&gt;  public static void getCoffeesBoughtBySupplier (String supplierName, Connection con, String dbName)
    throws SQLException {
    Statement stmt = null;
    String query = &quot;SELECT COFFEES.COF_NAME &quot; +
       &quot;FROM COFFEES, SUPPLIERS &quot; +
       &quot;WHERE SUPPLIERS.SUP_NAME LIKE &#39;&quot; + supplierName + &quot;&#39; &quot; +
       &quot;and SUPPLIERS.SUP_ID = COFFEES.SUP_ID&quot;;

    try {
      stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery(query);
      System.out.println(&quot;Coffees bought from &quot; + supplierName + &quot;: &quot;);
      while (rs.next()) {
          String coffeeName = rs.getString(1);
          System.out.println(&quot;     &quot; + coffeeName);
      }
    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
        stmt.close();
    }
  }&lt;/pre&gt;
If you call this method with the argument &lt;code&gt;supplierName&lt;/code&gt; set to &lt;code&gt;Acme, Inc.&lt;/code&gt;, it will produce the following output:&lt;br /&gt;


&lt;blockquote&gt;
&lt;pre&gt;Coffees bought from Acme, Inc.:
     Colombian
     Colombian_Decaf&lt;/pre&gt;
&lt;/blockquote&gt;
The following line retrieves the value from the first column of the &lt;code&gt;ResultSet&lt;/code&gt; object:&lt;br /&gt;


&lt;pre&gt;          String coffeeName = rs.getString(&lt;code&gt;1&lt;/code&gt;);&lt;/pre&gt;
Note that the &lt;code&gt;ResultSet&lt;/code&gt; object in this example contains only one column.&lt;br /&gt;
        &lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/2247953689421189197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcusing-joins.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/2247953689421189197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/2247953689421189197'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcusing-joins.html' title='JDBC:Using Joins'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-989053049194424007</id><published>2011-01-15T12:48:00.000-08:00</published><updated>2011-01-15T12:48:00.336-08:00</updated><title type='text'>JDBC:Retrieving and Modifying Values from Result Sets</title><content type='html'>&lt;br /&gt;
&lt;div id=&quot;PageTitle&quot;&gt;
Retrieving and Modifying Values from Result Sets&lt;/div&gt;
&lt;blockquote&gt;

The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.viewTable&lt;/a&gt;&lt;/code&gt; outputs the contents of the &lt;code&gt;COFFEES&lt;/code&gt; tables, and demonstrates the use of &lt;code&gt;ResultSet&lt;/code&gt; objects and cursors:&lt;br /&gt;


&lt;pre&gt;  public static void viewTable(Connection con) throws SQLException {
    Statement stmt = null;
    String query = &quot;select COF_NAME, SUP_ID, PRICE, SALES, TOTAL from &quot; + dbName + &quot;.COFFEES&quot;;
    try {
      stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery(query);
      while (rs.next()) {
        String coffeeName = rs.getString(&quot;COF_NAME&quot;);
        int supplierID = rs.getInt(&quot;SUP_ID&quot;);
        float price = rs.getFloat(&quot;PRICE&quot;);
        int sales = rs.getInt(&quot;SALES&quot;);
        int total = rs.getInt(&quot;TOTAL&quot;);
        System.out.println(coffeeName + &quot;\t&quot; + supplierID + &quot;\t&quot; + price + &quot;\t&quot; + sales + &quot;\t&quot; + total);
      }
    } catch (SQLException e ) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      stmt.close();
    }
  }&lt;/pre&gt;
A &lt;code&gt;ResultSet&lt;/code&gt; object is a table of data representing a 
database result set, which is usually generated by executing a statement
 that queries the database. For example, the &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeeTables.viewTable&lt;/a&gt;&lt;/code&gt; method creates a &lt;code&gt;ResultSet&lt;/code&gt;, &lt;code&gt;rs&lt;/code&gt;, when it executes the query through the &lt;code&gt;Statement&lt;/code&gt; object, &lt;code&gt;stmt&lt;/code&gt;. Note that a &lt;code&gt;ResultSet&lt;/code&gt; object can be created through any object that implements the &lt;code&gt;Statement&lt;/code&gt; interface, including &lt;code&gt;PreparedStatement&lt;/code&gt;, &lt;code&gt;CallableStatement&lt;/code&gt;, and &lt;code&gt;RowSet&lt;/code&gt;.&lt;br /&gt;


You access the data in a &lt;code&gt;ResultSet&lt;/code&gt; object through a 
cursor. Note that this cursor is not a database cursor. This cursor is a
 pointer that points to one row of data in the &lt;code&gt;ResultSet&lt;/code&gt;. Initially, the cursor is positioned before the first row. The method &lt;code&gt;ResultSet.next&lt;/code&gt; moves the cursor to the next row. This method returns &lt;code&gt;false&lt;/code&gt; if the cursor is positioned after the last row. This method repeatedly calls the &lt;code&gt;ResultSet.next&lt;/code&gt; method with a &lt;code&gt;while&lt;/code&gt; loop to iterate through all the data in the &lt;code&gt;ResultSet&lt;/code&gt;.&lt;br /&gt;




&lt;h3&gt;
ResultSet Interface&lt;/h3&gt;
The &lt;code&gt;ResultSet&lt;/code&gt; interface provides methods for retrieving and manipulating the results of executed queries, and &lt;code&gt;ResultSet&lt;/code&gt; objects can have different functionality and characteristics. These characteristics are type, concurrency, and cursor &lt;em&gt;holdability&lt;/em&gt;.&lt;br /&gt;




&lt;h4&gt;
ResultSet Types&lt;/h4&gt;
The type of a &lt;code&gt;ResultSet&lt;/code&gt; object determines the level of 
its functionality in two areas: the ways in which the cursor can be 
manipulated, and how concurrent changes made to the underlying data 
source are reflected by the &lt;code&gt;ResultSet&lt;/code&gt; object.&lt;br /&gt;


The sensitivity of a &lt;code&gt;ResultSet&lt;/code&gt; object is determined by one of three different &lt;code&gt;ResultSet&lt;/code&gt; types:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;TYPE_FORWARD_ONLY&lt;/code&gt;: The result set cannot be 
scrolled; its cursor moves forward only, from before the first row to 
after the last row. The rows contained in the result set depend on how 
the underlying database generates the results. That is, it contains the 
rows that satisfy the query at either the time the query is executed or 
as the rows are retrieved.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;TYPE_SCROLL_INSENSITIVE&lt;/code&gt;: The result cannot be 
scrolled; its cursor can move both forward and backward relative to the 
current position, and it can move to an absolute position. The result 
set is insensitive to changes made to the underlying data source while 
it is open. It contains the rows that satisfy the query at either the 
time the query is executed or as the rows are retrieved.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;TYPE_SCROLL_SENSITIVE&lt;/code&gt;: The result can be scrolled; 
its cursor can move both forward and backward relative to the current 
position, and it can move to an absolute position. The result set 
reflects changes made to the underlying data source while the result set
 remains open.&lt;/li&gt;
&lt;/ul&gt;
The default &lt;code&gt;ResultSet&lt;/code&gt; type is &lt;code&gt;TYPE_FORWARD_ONLY&lt;/code&gt;.&lt;br /&gt;




&lt;h4&gt;
ResultSet Concurrency&lt;/h4&gt;
The concurrency of a &lt;code&gt;ResultSet&lt;/code&gt; object determines what level of update functionality is supported.&lt;br /&gt;


There are two concurrency levels:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;CONCUR_READ_ONLY&lt;/code&gt;: The &lt;code&gt;ResultSet&lt;/code&gt; object cannot be updated using the &lt;code&gt;ResultSet&lt;/code&gt; interface.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;CONCUR_UPDATABLE&lt;/code&gt;: The &lt;code&gt;ResultSet&lt;/code&gt; object can be updated using the &lt;code&gt;ResultSet&lt;/code&gt; interface.&lt;/li&gt;
&lt;/ul&gt;
The default &lt;code&gt;ResultSet&lt;/code&gt; concurrency is &lt;code&gt;CONCUR_READ_ONLY&lt;/code&gt;.&lt;br /&gt;


&lt;strong&gt;Note&lt;/strong&gt;: Not all JDBD drivers and databases support concurrency. The method &lt;code&gt;DatabaseMetaData.supportsResultSetConcurrency&lt;/code&gt; returns &lt;code&gt;true&lt;/code&gt; if the specified concurrency level is supported by the driver and &lt;code&gt;false&lt;/code&gt; otherwise.&lt;br /&gt;


The method &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.modifyPrices&lt;/a&gt;&lt;/code&gt; demonstrates how to use a &lt;code&gt;ResultSet&lt;/code&gt; object whose concurrency level is &lt;code&gt;CONCUR_UPDATABLE&lt;/code&gt;.&lt;br /&gt;




&lt;h4&gt;
Cursor Holdability&lt;/h4&gt;
Calling the method &lt;code&gt;Connection.commit&lt;/code&gt; can close the &lt;code&gt;ResultSet&lt;/code&gt; objects that
have been created during the current transaction. In some cases, however, this may
not be the desired behavior. The &lt;code&gt;ResultSet&lt;/code&gt; property &lt;em&gt;holdability&lt;/em&gt; gives the
application control over whether &lt;code&gt;ResultSet&lt;/code&gt; objects (cursors) are closed when
commit is called.&lt;br /&gt;


The following &lt;code&gt;ResultSet&lt;/code&gt; constants may be supplied to the &lt;code&gt;Connection&lt;/code&gt; methods
&lt;code&gt;createStatement&lt;/code&gt;, &lt;code&gt;prepareStatement&lt;/code&gt;, and &lt;code&gt;prepareCall&lt;/code&gt;:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;HOLD_CURSORS_OVER_COMMIT&lt;/code&gt;: &lt;code&gt;ResultSet&lt;/code&gt; cursors are not closed; they are &lt;em&gt;holdable&lt;/em&gt;: they are held open when the method &lt;code&gt;commit&lt;/code&gt; is called. Holdable cursors might be ideal if your application uses mostly read-only &lt;code&gt;ResultSet&lt;/code&gt; objects.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;CLOSE_CURSORS_AT_COMMIT&lt;/code&gt;: &lt;code&gt;ResultSet&lt;/code&gt; objects (cursors) are closed when the &lt;code&gt;commit&lt;/code&gt; method is called. Closing cursors when this method is called can result in better performance for some applications.&lt;/li&gt;
&lt;/ul&gt;
The default cursor holdability varies depending on your DBMS.&lt;br /&gt;


&lt;strong&gt;Note&lt;/strong&gt;: Not all JDBD drivers and databases support holdable and non-holdable cursors. The following method, &lt;code&gt;JDBCTutorialUtilities.cursorHoldabilitySupport&lt;/code&gt;, outputs the default cursor holdability of &lt;code&gt;ResultSet&lt;/code&gt; objects and whether &lt;code&gt;HOLD_CURSORS_OVER_COMMIT&lt;/code&gt; and &lt;code&gt;CLOSE_CURSORS_AT_COMMIT&lt;/code&gt; are supported:&lt;br /&gt;


&lt;pre&gt;  public static void cursorHoldabilitySupport(Connection conn) throws SQLException {
    DatabaseMetaData dbMetaData = conn.getMetaData();
    System.out.println(&quot;ResultSet.HOLD_CURSORS_OVER_COMMIT = &quot; + ResultSet.HOLD_CURSORS_OVER_COMMIT);
    System.out.println(&quot;ResultSet.CLOSE_CURSORS_AT_COMMIT = &quot; + ResultSet.CLOSE_CURSORS_AT_COMMIT);
    System.out.println(&quot;Default cursor holdability: &quot; +
      &lt;strong&gt;dbMetaData.getResultSetHoldability()&lt;/strong&gt;);
    System.out.println(&quot;Supports HOLD_CURSORS_OVER_COMMIT? &quot; +
      &lt;strong&gt;dbMetaData.supportsResultSetHoldability(
        ResultSet.HOLD_CURSORS_OVER_COMMIT)&lt;/strong&gt;);
    System.out.println(&quot;Supports CLOSE_CURSORS_AT_COMMIT? &quot; +
      &lt;strong&gt;dbMetaData.supportsResultSetHoldability(
        ResultSet.CLOSE_CURSORS_AT_COMMIT)&lt;/strong&gt;);
  }&lt;/pre&gt;
&lt;h3&gt;
Retrieving Column Values from Rows&lt;/h3&gt;
The &lt;code&gt;ResultSet&lt;/code&gt; interface declares getter methods (for example, &lt;code&gt;getBoolean&lt;/code&gt; and &lt;code&gt;getLong&lt;/code&gt;)
 for retrieving column values from the current row. You can retrieve 
values using either the index number of the column or the name of the 
column. The column index is usually more efficient. Columns are numbered
 from 1. For maximum portability, result set columns within each row 
should be read in left-to-right order, and each column should be read 
only once.&lt;br /&gt;


For example, the following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.alternateViewTable&lt;/a&gt;&lt;/code&gt;, retrieves column values by number:&lt;br /&gt;


&lt;pre&gt;  public static void alternateViewTable(Connection con) throws SQLException {
    Statement stmt = null;
    String query = &quot;select COF_NAME, SUP_ID, PRICE, SALES, TOTAL from COFFEES&quot;;
    try {
      stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery(query);
      while (rs.next()) {
        String coffeeName = rs.getString(1);
        int supplierID = rs.getInt(2);
        float price = rs.getFloat(3);
        int sales = rs.getInt(4);
        int total = rs.getInt(5);
        System.out.println(coffeeName + &quot;\t&quot; + supplierID + &quot;\t&quot; + price + &quot;\t&quot; + sales + &quot;\t&quot; + total);
      }
    } catch (SQLException e ) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      stmt.close();
    }
  }&lt;/pre&gt;
Column names used as input to getter methods are case-insensitive. 
When a getter method is called with a column name and several columns 
have the same name, the value of the first matching column is returned. 
The column name option is designed to be used when column names are used
 in the SQL query that generated the result set. For columns that are &lt;em&gt;not&lt;/em&gt;
 explicitly named in the query, it is best to use column numbers. If 
column names are used, the developer should guarantee that they uniquely
 refer to the intended columns, which can be ensured by using the SQL &lt;code&gt;AS&lt;/code&gt; clause.&lt;br /&gt;


The getter method of the appropriate type retrieves the value in each column. For example, in the method &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeeTables.viewTable&lt;/a&gt;&lt;/code&gt;, the first column in each row of the &lt;code&gt;ResultSet&lt;/code&gt; &lt;code&gt;rs&lt;/code&gt; is &lt;code&gt;COF_NAME&lt;/code&gt;, which stores a value of SQL type &lt;code&gt;VARCHAR&lt;/code&gt;. The method for retrieving a value of SQL type &lt;code&gt;VARCHAR&lt;/code&gt; is &lt;code&gt;getString&lt;/code&gt;. The second column in each row stores a value of SQL type &lt;code&gt;INTEGER&lt;/code&gt;, and the method for retrieving values of that type is &lt;code&gt;getInt&lt;/code&gt;.&lt;br /&gt;


Note that although the method &lt;code&gt;getString&lt;/code&gt; is recommended for retrieving the SQL types &lt;code&gt;CHAR&lt;/code&gt; and &lt;code&gt;VARCHAR&lt;/code&gt;, it is possible to retrieve any of the basic SQL types with it. Getting all values with &lt;code&gt;getString&lt;/code&gt; can be very useful, but it also has its limitations. For instance, if it is used to retrieve a numeric type, &lt;code&gt;getString&lt;/code&gt; converts the numeric value to a Java &lt;code&gt;String&lt;/code&gt;
 object, and the value has to be converted back to a numeric type before
 it can be operated on as a number. In cases where the value is treated 
as a string anyway, there is no drawback. Furthermore, if you want an 
application to retrieve values of any standard SQL type other than SQL3 
types, use the &lt;code&gt;getString&lt;/code&gt; method.&lt;br /&gt;






&lt;h3&gt;
Cursors&lt;/h3&gt;
As mentioned previously, you access the data in a &lt;code&gt;ResultSet&lt;/code&gt; object through a cursor, which points to one row in the &lt;code&gt;ResultSet&lt;/code&gt; object. However, when a &lt;code&gt;ResultSet&lt;/code&gt; object is first created, the cursor is positioned before the first row. The method &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeeTables.viewTable&lt;/a&gt;&lt;/code&gt; moves the cursor by calling the &lt;code&gt;ResultSet.next&lt;/code&gt; method. There are other methods available to move the cursor:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;next&lt;/code&gt;: Moves the cursor forward one row. Returns &lt;code&gt;true&lt;/code&gt; if the cursor is now positioned on a row and &lt;code&gt;false&lt;/code&gt; if the cursor is positioned after the last row.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;previous&lt;/code&gt;: Moves the cursor backward one row. Returns &lt;code&gt;true&lt;/code&gt; if the cursor is now positioned on a row and &lt;code&gt;false&lt;/code&gt; if the cursor is positioned before the first row.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;first&lt;/code&gt;: Moves the cursor to the first row in the &lt;code&gt;ResultSet&lt;/code&gt; object. Returns &lt;code&gt;true&lt;/code&gt; if the cursor is now positioned on the first row and &lt;code&gt;false&lt;/code&gt; if the &lt;code&gt;ResultSet&lt;/code&gt; object does not contain any rows.

  &lt;/li&gt;
&lt;li&gt;&lt;code&gt;last:&lt;/code&gt;: Moves the cursor to the last row in the &lt;code&gt;ResultSet&lt;/code&gt; object. Returns &lt;code&gt;true&lt;/code&gt; if the cursor is now positioned on the last row and &lt;code&gt;false&lt;/code&gt; if the &lt;code&gt;ResultSet&lt;/code&gt; object does not contain any rows.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;beforeFirst&lt;/code&gt;: Positions the cursor at the start of the &lt;code&gt;ResultSet&lt;/code&gt; object, before the first row. If the &lt;code&gt;ResultSet&lt;/code&gt; object does not contain any rows, this method has no effect.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;afterLast&lt;/code&gt;: Positions the cursor at the end of the &lt;code&gt;ResultSet&lt;/code&gt; object, after the last row. If the &lt;code&gt;ResultSet&lt;/code&gt; object does not contain any rows, this method has no effect.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;relative(int rows)&lt;/code&gt;: Moves the cursor relative to its current position.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;absolute(int row)&lt;/code&gt;: Positions the cursor on the row specified by the parameter &lt;code&gt;row&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
Note that the default sensitivity of a &lt;code&gt;ResultSet&lt;/code&gt; is &lt;code&gt;TYPE_FORWARD_ONLY&lt;/code&gt;, which means that it cannot be scrolled; you cannot call any of these methods that move the cursor, except &lt;code&gt;next&lt;/code&gt;, if your &lt;code&gt;ResultSet&lt;/code&gt; cannot be scrolled. The method &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.modifyPrices&lt;/a&gt;&lt;/code&gt;, described in the following section, demonstrates how you can move the cursor of a &lt;code&gt;ResultSet&lt;/code&gt;.&lt;br /&gt;





&lt;h3&gt;
Updating Rows in ResultSet Objects&lt;/h3&gt;
You cannot update a default &lt;code&gt;ResultSet&lt;/code&gt; object, and you can only move its cursor forward. However, you can create &lt;code&gt;ResultSet&lt;/code&gt; objects that can be scrolled (the cursor can move backwards or move to an absolute position) and updated.&lt;br /&gt;


The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.modifyPrices&lt;/a&gt;&lt;/code&gt;, multiplies the &lt;code&gt;PRICE&lt;/code&gt; column of each row by the argument &lt;code&gt;percentage&lt;/code&gt;:&lt;br /&gt;


&lt;pre&gt;  public void modifyPrices(float percentage) throws SQLException {
    Statement stmt = null;
    try {
      stmt = con.createStatement();
      stmt = con.createStatement(
        ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
      ResultSet uprs = stmt.executeQuery(
        &quot;SELECT * FROM &quot; + dbName + &quot;.COFFEES&quot;);

      while (uprs.next()) {
        float f = uprs.getFloat(&quot;PRICE&quot;);
        uprs.updateFloat(&quot;PRICE&quot;, f * percentage);
        uprs.updateRow();
      }

    } catch (SQLException e ) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      stmt.close();
    }
  }&lt;/pre&gt;
The field &lt;code&gt;ResultSet.TYPE_SCROLL_SENSITIVE&lt;/code&gt; creates a &lt;code&gt;ResultSet&lt;/code&gt; object whose cursor can move both forward and backward relative to the current position and to an absolute position. The field &lt;code&gt;ResultSet.CONCUR_UPDATABLE&lt;/code&gt; creates a &lt;code&gt;ResultSet&lt;/code&gt; object that can be updated. See the &lt;code&gt;ResultSet&lt;/code&gt; Javadoc for other fields you can specify to modify the behavior of &lt;code&gt;ResultSet&lt;/code&gt; objects.&lt;br /&gt;


The method &lt;code&gt;ResultSet.updateFloat&lt;/code&gt; updates the specified column (in this example, &lt;code&gt;PRICE&lt;/code&gt; with the specified &lt;code&gt;float&lt;/code&gt; value in the row where the cursor is positioned. &lt;code&gt;ResultSet&lt;/code&gt;
 contains various updater methods that enable you to update column 
values of various data types. However, none of these updater methods 
modifies the database; you must call the method &lt;code&gt;ResultSet.updateRow&lt;/code&gt; to update the database.&lt;br /&gt;




&lt;h3&gt;
Using Statement Objects for Batch Updates&lt;/h3&gt;
&lt;code&gt;Statement&lt;/code&gt;, &lt;code&gt;PreparedStatement&lt;/code&gt; and &lt;code&gt;CallableStatement&lt;/code&gt;
 objects have a list of commands that is associated with them. This list
 may contain statements for updating, inserting, or deleting a row; and 
it may also contain DDL statements such as &lt;code&gt;CREATE TABLE&lt;/code&gt; and &lt;code&gt;DROP TABLE&lt;/code&gt;. It cannot, however, contain a statement that would produce a &lt;code&gt;ResultSet&lt;/code&gt; object, such as a &lt;code&gt;SELECT&lt;/code&gt; statement. In other words, the list can contain only statements that produce an update count.&lt;br /&gt;


The list, which is associated with a &lt;code&gt;Statement&lt;/code&gt; object at its creation, is initially empty. You can add SQL commands to this list with the method &lt;code&gt;addBatch&lt;/code&gt; and empty it with the method &lt;code&gt;clearBatch&lt;/code&gt;. When you have finished adding statements to the list, call the method &lt;code&gt;executeBatch&lt;/code&gt; to send them all to the database to be executed as a unit, or batch.&lt;br /&gt;


For example, the following method &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.batchUpdate&lt;/a&gt;&lt;/code&gt; adds four rows to the &lt;code&gt;COFFEES&lt;/code&gt; table with a batch update:&lt;br /&gt;


&lt;pre&gt;  public void batchUpdate() throws SQLException {

    Statement stmt = null;
    try {

      this.con.setAutoCommit(false);
      stmt = this.con.createStatement();

      stmt.addBatch(&quot;INSERT INTO COFFEES &quot; +
               &quot;VALUES(&#39;Amaretto&#39;, 49, 9.99, 0, 0)&quot;);
      stmt.addBatch(&quot;INSERT INTO COFFEES &quot; +
               &quot;VALUES(&#39;Hazelnut&#39;, 49, 9.99, 0, 0)&quot;);
      stmt.addBatch(&quot;INSERT INTO COFFEES &quot; +
               &quot;VALUES(&#39;Amaretto_decaf&#39;, 49, 10.99, 0, 0)&quot;);
      stmt.addBatch(&quot;INSERT INTO COFFEES &quot; +
               &quot;VALUES(&#39;Hazelnut_decaf&#39;, 49, 10.99, 0, 0)&quot;);

      int [] updateCounts = stmt.executeBatch();
      this.con.commit();

    } catch(BatchUpdateException b) {
      JDBCTutorialUtilities.printBatchUpdateException(b);
    } catch(SQLException ex) {
      JDBCTutorialUtilities.printSQLException(ex);
    } finally {
      this.con.setAutoCommit(true);
      stmt.close();
    }
  }&lt;/pre&gt;
The following line disables auto-commit mode for the &lt;code&gt;Connection&lt;/code&gt; object con so that the transaction will not be automatically committed or rolled back when the method &lt;code&gt;executeBatch&lt;/code&gt; is called.

&lt;br /&gt;
&lt;pre&gt;      this.con.setAutoCommit(false);&lt;/pre&gt;
To allow for correct error handling, you should always disable auto-commit mode before beginning a batch update.&lt;br /&gt;


The method &lt;code&gt;Statement.addBatch&lt;/code&gt; adds a command to the list of commands associated with the &lt;code&gt;Statement&lt;/code&gt; object &lt;code&gt;stmt&lt;/code&gt;. In this example, these commands are all &lt;code&gt;INSERT INTO&lt;/code&gt; statements, each one adding a row consisting of five column values. The values for the columns &lt;code&gt;COF_NAME&lt;/code&gt; and &lt;code&gt;PRICE&lt;/code&gt;
 are the name of the coffee and its price, respectively. The second 
value in each row is 49 because that is the identification number for 
the supplier, Superior Coffee. The last two values, the entries for the 
columns &lt;code&gt;SALES&lt;/code&gt; and &lt;code&gt;TOTAL&lt;/code&gt;, all start out being zero because there have been no sales yet. (&lt;code&gt;SALES&lt;/code&gt; is the number of pounds of this row&#39;s coffee sold in the current week; &lt;code&gt;TOTAL&lt;/code&gt; is the total of all the cumulative sales of this coffee.)

&lt;br /&gt;
The following line sends the four SQL commands that were added to
 its list of commands to the database to be executed as a batch:&lt;br /&gt;


&lt;pre&gt;      int [] updateCounts = stmt.executeBatch();&lt;/pre&gt;
Note that &lt;code&gt;stmt&lt;/code&gt; uses the method &lt;code&gt;executeBatch&lt;/code&gt; to send the batch of insertions, not the method &lt;code&gt;executeUpdate&lt;/code&gt;,
 which sends only one command and returns a single update count. The 
DBMS executes the commands in the order in which they were added to the 
list of commands, so it will first add the row of values for Amaretto, 
then add the row for Hazelnut, then Amaretto decaf, and finally Hazelnut
 decaf. If all four commands execute successfully, the DBMS will return 
an update count for each command in the order in which it was executed. 
The update counts that indicate how many rows were affected by each 
command are stored in the array &lt;code&gt;updateCounts&lt;/code&gt;.

&lt;br /&gt;
If all four of the commands in the batch are executed successfully, &lt;code&gt;updateCounts&lt;/code&gt; will contain four values, all of which are 1 because an insertion affects one row. The list of commands associated with &lt;code&gt;stmt&lt;/code&gt; will now be empty because the four commands added previously were sent to the database when &lt;code&gt;stmt&lt;/code&gt; called the method &lt;code&gt;executeBatch&lt;/code&gt;. You can at any time explicitly empty this list of commands with the method &lt;code&gt;clearBatch&lt;/code&gt;.&lt;br /&gt;


The &lt;code&gt;Connection.commit&lt;/code&gt; method makes the batch of updates to the &lt;code&gt;COFFEES&lt;/code&gt;
 table permanent. This method needs to be called explicitly because the 
auto-commit mode for this connection was disabled previously.&lt;br /&gt;


The following line enables auto-commit mode for the current &lt;code&gt;Connection&lt;/code&gt; object.&lt;br /&gt;


&lt;pre&gt;      this.con.setAutoCommit(true);&lt;/pre&gt;
Now each statement in the example will automatically be committed 
after it is executed, and it no longer needs to invoke the method &lt;code&gt;commit&lt;/code&gt;.&lt;br /&gt;


&lt;h4&gt;
Performing Parameterized Batch Update&lt;/h4&gt;
It is also possible to have a parameterized batch update, as shown in the following code fragment, where &lt;code&gt;con&lt;/code&gt; is a &lt;code&gt;Connection&lt;/code&gt; object:&lt;br /&gt;


&lt;pre&gt;  con.setAutoCommit(false);
  PreparedStatement pstmt = con.prepareStatement(
                   &quot;INSERT INTO COFFEES VALUES(
                                ?, ?, ?, ?, ?)&quot;);
  pstmt.setString(1, &quot;Amaretto&quot;);
  pstmt.setInt(2, 49);
  pstmt.setFloat(3, 9.99);
  pstmt.setInt(4, 0);
  pstmt.setInt(5, 0);
  pstmt.addBatch();

  pstmt.setString(1, &quot;Hazelnut&quot;);
  pstmt.setInt(2, 49);
  pstmt.setFloat(3, 9.99);
  pstmt.setInt(4, 0);
  pstmt.setInt(5, 0);
  pstmt.addBatch();

  &lt;strong&gt;// ... and so on for each new type of coffee&lt;/strong&gt;

  int [] updateCounts = pstmt.executeBatch();
  con.commit();
  con.setAutoCommit(true);&lt;/pre&gt;
&lt;h4&gt;
Handling Batch Update Exceptions&lt;/h4&gt;
You will get a &lt;code&gt;BatchUpdateException&lt;/code&gt; when you call the method &lt;code&gt;executeBatch&lt;/code&gt;
 if (1) one of the SQL statements you added to the batch produces a 
result set (usually a query) or (2) one of the SQL statements in the 
batch does not execute successfully for some other reason.&lt;br /&gt;


You should not add a query (a &lt;code&gt;SELECT&lt;/code&gt; statement) to a batch of SQL commands because the method &lt;code&gt;executeBatch&lt;/code&gt;,
 which returns an array of update counts, expects an update count from 
each SQL statement that executes successfully. This means that only 
commands that return an update count (commands such as &lt;code&gt;INSERT INTO&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;) or that return 0 (such as &lt;code&gt;CREATE TABLE&lt;/code&gt;, &lt;code&gt;DROP TABLE&lt;/code&gt;, &lt;code&gt;ALTER TABLE&lt;/code&gt;) can be successfully executed as a batch with the &lt;code&gt;executeBatch&lt;/code&gt; method.&lt;br /&gt;


A &lt;code&gt;BatchUpdateException&lt;/code&gt; contains an array of update counts that is similar to the array returned by the method &lt;code&gt;executeBatch&lt;/code&gt;.
 In both cases, the update counts are in the same order as the commands 
that produced them. This tells you how many commands in the batch 
executed successfully and which ones they are. For example, if five 
commands executed successfully, the array will contain five numbers: the
 first one being the update count for the first command, the second one 
being the update count for the second command, and so on.&lt;br /&gt;


&lt;code&gt;BatchUpdateException&lt;/code&gt; is derived from &lt;code&gt;SQLException&lt;/code&gt;. This means that you can use all of the methods available to an &lt;code&gt;SQLException&lt;/code&gt; object with it. The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;JDBCTutorialUtilities.printBatchUpdateException&lt;/a&gt;&lt;/code&gt; prints all of the &lt;code&gt;SQLException&lt;/code&gt; information plus the update counts contained in a &lt;code&gt;BatchUpdateException&lt;/code&gt; object. Because &lt;code&gt;BatchUpdateException.getUpdateCounts&lt;/code&gt; returns an array of &lt;code&gt;int&lt;/code&gt;, the code uses a &lt;code&gt;for&lt;/code&gt; loop to print each of the update counts:&lt;br /&gt;


&lt;pre&gt;  public static void printBatchUpdateException(BatchUpdateException b) {
    System.err.println(&quot;----BatchUpdateException----&quot;);
    System.err.println(&quot;SQLState:  &quot; + b.getSQLState());
    System.err.println(&quot;Message:  &quot; + b.getMessage());
    System.err.println(&quot;Vendor:  &quot; + b.getErrorCode());
    System.err.print(&quot;Update counts:  &quot;);
    int [] updateCounts = b.getUpdateCounts();
    for (int i = 0; i &amp;lt; updateCounts.length; i++) {
      System.err.print(updateCounts[i] + &quot;   &quot;);
    }
  }&lt;/pre&gt;
&lt;h3&gt;
Inserting Rows in ResultSet Objects&lt;/h3&gt;
&lt;strong&gt;Note&lt;/strong&gt;: Not all JDBD drivers support inserting new rows with the &lt;code&gt;ResultSet&lt;/code&gt; interface. If you attempt to insert a new row and your JDBC driver database does not support this feature, a &lt;code&gt;SQLFeatureNotSupportedException&lt;/code&gt; exception is thrown.&lt;br /&gt;


The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.insertRow&lt;/a&gt;&lt;/code&gt;, inserts a row into the &lt;code&gt;COFFEES&lt;/code&gt; through a &lt;code&gt;ResultSet&lt;/code&gt; object:&lt;br /&gt;


&lt;pre&gt;  public void insertRow(String coffeeName, int supplierID, float price, int sales, int total)
    throws SQLException {
    Statement stmt = null;
    try {
      stmt = con.createStatement();
      stmt = con.createStatement(
        ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
      ResultSet uprs = stmt.executeQuery(
        &quot;SELECT * FROM &quot; + dbName + &quot;.COFFEES&quot;);

      uprs.moveToInsertRow();

      uprs.updateString(&quot;COF_NAME&quot;, coffeeName);
      uprs.updateInt(&quot;SUP_ID&quot;, supplierID);
      uprs.updateFloat(&quot;PRICE&quot;, price);
      uprs.updateInt(&quot;SALES&quot;, sales);
      uprs.updateInt(&quot;TOTAL&quot;, total);

      uprs.insertRow();
      uprs.beforeFirst();

    } catch (SQLException e ) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      stmt.close();
    }
  }&lt;/pre&gt;
The method &lt;code&gt;ResultSet.moveToInsertRow&lt;/code&gt; moves the cursor to
 the insert row. The insert row is a special row associated with an 
updatable result set. It is essentially a buffer where a new row can be 
constructed by calling the updater methods prior to inserting the row 
into the result set. For example, this method calls the method &lt;code&gt;ResultSet.updateString&lt;/code&gt; to update the insert row&#39;s &lt;code&gt;COF_NAME&lt;/code&gt; column to &lt;code&gt;Kona&lt;/code&gt;.&lt;br /&gt;


The method &lt;code&gt;ResultSet.insertRow&lt;/code&gt; inserts the contents of the insert row into the &lt;code&gt;ResultSet&lt;/code&gt; object and into the database.&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/989053049194424007/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcretrieving-and-modifying-values.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/989053049194424007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/989053049194424007'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcretrieving-and-modifying-values.html' title='JDBC:Retrieving and Modifying Values from Result Sets'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-4250595349778652666</id><published>2011-01-15T12:46:00.001-08:00</published><updated>2011-01-15T12:46:23.588-08:00</updated><title type='text'>JDBC:Setting Up Tables</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
Setting Up Tables&lt;/div&gt;
The sample &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.java&lt;/a&gt;&lt;/code&gt; creates the following table and data:&lt;br /&gt;


&lt;table border=&quot;1&quot; summary=&quot;COFFEES table&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;th&gt;COF_NAME&lt;/th&gt;
    &lt;th&gt;SUP_ID&lt;/th&gt;
    &lt;th&gt;PRICE&lt;/th&gt;
    &lt;th&gt;SALES&lt;/th&gt;
    &lt;th&gt;TOTAL&lt;/th&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Colombian&lt;/td&gt;
    &lt;td&gt;101&lt;/td&gt;
    &lt;td&gt;7.99&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;French_Roast&lt;/td&gt;
    &lt;td&gt;49&lt;/td&gt;
    &lt;td&gt;8.99&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Espresso&lt;/td&gt;
    &lt;td&gt;150&lt;/td&gt;
    &lt;td&gt;9.99&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Colombian_Decaf&lt;/td&gt;
    &lt;td&gt;101&lt;/td&gt;
    &lt;td&gt;8.99&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;French_Roast_Decaf&lt;/td&gt;
    &lt;td&gt;49&lt;/td&gt;
    &lt;td&gt;9.99&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
The following describes each of the columns in the &lt;code&gt;COFFEES&lt;/code&gt; table:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;COF_NAME&lt;/code&gt;: Stores the coffee name. Holds values with a SQL type of &lt;code&gt;VARCHAR&lt;/code&gt;
 with a maximum length of 32 characters. Because the names are different
 for each type of coffee sold, the name uniquely identifies a particular
 coffee and serves as the primary key.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SUP_ID&lt;/code&gt;: Stores a number identifying the coffee supplier. Holds values with a SQL type of &lt;code&gt;INTEGER&lt;/code&gt;. It is defined as a foreign key that references the column &lt;code&gt;SUP_ID&lt;/code&gt; in the &lt;code&gt;SUPPLIERS&lt;/code&gt;
 table. Consequently, the DBMS will enforce that each value in this 
column matches one of the values in the corresponding column in the &lt;code&gt;SUPPLIERS&lt;/code&gt; table.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PRICE&lt;/code&gt;: Stores the cost of the coffee pet pound. Holds values with a SQL type of &lt;code&gt;FLOAT&lt;/code&gt; because it needs to hold values with decimal points. (Note that money values would typically be stored in a SQL type &lt;code&gt;DECIMAL&lt;/code&gt; or &lt;code&gt;NUMERIC&lt;/code&gt;,
 but because of differences among DBMSs and to avoid incompatibility 
with earlier versions of JDBC, the tutorial uses the more standard type &lt;code&gt;FLOAT&lt;/code&gt;.)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SALES&lt;/code&gt;: Stores the number of pounds of coffee sold during the current week. Holds values with a SQL type of &lt;code&gt;INTEGER&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;TOTAL&lt;/code&gt;: Stores the number of pounds of coffee sold to date. Holds values with a SQL type of &lt;code&gt;INTEGER&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;code&gt;SUPPLIERS&lt;/code&gt;, the second table in the database, stores information about each of the suppliers:&lt;br /&gt;



&lt;table border=&quot;1&quot; summary=&quot;SUPPLIERS table&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;SUP_ID&lt;/th&gt;
  &lt;th&gt;SUP_NAME&lt;/th&gt;
  &lt;th&gt;STREET&lt;/th&gt;
  &lt;th&gt;CITY&lt;/th&gt;
  &lt;th&gt;STATE&lt;/th&gt;
  &lt;th&gt;ZIP&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;101&lt;/td&gt;
  &lt;td&gt;Acme, Inc.&lt;/td&gt;
  &lt;td&gt;99 Market Street&lt;/td&gt;
  &lt;td&gt;Groundsville&lt;/td&gt;
  &lt;td&gt;CA&lt;/td&gt;
  &lt;td&gt;95199&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;49&lt;/td&gt;
  &lt;td&gt;Superior Coffee&lt;/td&gt;
  &lt;td&gt;1 Party Place&lt;/td&gt;
  &lt;td&gt;Mendocino&lt;/td&gt;
  &lt;td&gt;CA&lt;/td&gt;
  &lt;td&gt;95460&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;150&lt;/td&gt;
  &lt;td&gt;The High Ground&lt;/td&gt;
  &lt;td&gt;100 Coffee Lane&lt;/td&gt;
  &lt;td&gt;Meadows&lt;/td&gt;
  &lt;td&gt;CA&lt;/td&gt;
  &lt;td&gt;93966&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
The following describes each of the columns in the &lt;code&gt;SUPPLIERS&lt;/code&gt; table:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;SUP_ID&lt;/code&gt;: Stores a number identifying the coffee supplier. Holds values with a SQL type of &lt;code&gt;INTEGER&lt;/code&gt;. It is the primary key in this table.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SUP_NAME&lt;/code&gt;: Stores the name of the coffee supplier.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;STREET&lt;/code&gt;, &lt;code&gt;CITY&lt;/code&gt;, &lt;code&gt;STATE&lt;/code&gt;, and &lt;code&gt;ZIP&lt;/code&gt;: These columns store the address of the coffee supplier.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
Creating Tables&lt;/h3&gt;
You can create tables with Apache Ant or JDBC API.&lt;br /&gt;


&lt;h4&gt;
Creating Tables with Apache Ant&lt;/h4&gt;
To create the &lt;code&gt;SUPPLIERS&lt;/code&gt; and &lt;code&gt;COFFEES&lt;/code&gt; tables with the tutorial sample code, run the following command in the directory &lt;code&gt;&lt;em&gt;&amp;lt;JDBC tutorial directory&amp;gt;&lt;/em&gt;&lt;/code&gt;:

&lt;br /&gt;
&lt;pre&gt;ant create-tables&lt;/pre&gt;
This command runs the following Ant target (from the &lt;code&gt;build.xml&lt;/code&gt; file):&lt;br /&gt;


&lt;pre&gt;  &amp;lt;target name=&quot;build-tables&quot; description=&quot;Create database tables&quot;&amp;gt;
    &amp;lt;sql
      driver=&quot;${DB.DRIVER}&quot;
      url=&quot;${DB.URL}&quot;
      userid=&quot;${DB.USER}&quot;
      password=&quot;${DB.PASSWORD}&quot;
      classpathref=&quot;CLASSPATH&quot;
      delimiter=&quot;${DB.DELIMITER}&quot; autocommit=&quot;false&quot; onerror=&quot;abort&quot;&amp;gt;
       &amp;lt;transaction src=&quot;./sql/${DB.VENDOR}/create-tables.sql&quot;/&amp;gt;
    &amp;lt;/sql&amp;gt;
  &amp;lt;/target&amp;gt;&lt;/pre&gt;
The sample specifies values for the following &lt;code&gt;sql&lt;/code&gt; Ant task parameters:&lt;br /&gt;


&lt;table border=&quot;1&quot; summary=&quot;Ant parameters&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;Parameter&lt;/th&gt;
  &lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;driver&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Fully qualified class name of your JDBC driver. This sample uses &lt;code&gt;org.apache.derby.jdbc.EmbeddedDriver&lt;/code&gt; for Java DB and &lt;code&gt;com.mysql.jdbc.Driver&lt;/code&gt; for MySQL Connector/J.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;url&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Database connection URL that your DBMS JDBC driver uses to connect to a database.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;userid&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Name of a valid user in your DBMS.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;password&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Password of the user specified in &lt;code&gt;userid&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;classpathref&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Full path name of the JAR file that contains the class specified in &lt;code&gt;driver&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;delimiter&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;String or character that separates SQL statements. This sample uses the semicolon (&lt;code&gt;;&lt;/code&gt;).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;autocommit&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Boolean value; if set to &lt;code&gt;false&lt;/code&gt;, all SQL statements are executed as one transaction.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;code&gt;onerror&lt;/code&gt;&lt;/td&gt;
  &lt;td&gt;Action to perform when a statement fails; possible values are &lt;code&gt;continue&lt;/code&gt;, &lt;code&gt;stop&lt;/code&gt;, and &lt;code&gt;abort&lt;/code&gt;. The value &lt;code&gt;abort&lt;/code&gt; specifies that if an error occurs, the transaction is aborted.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
The sample stores the values of these parameters in a separate file. The build file &lt;code&gt;build.xml&lt;/code&gt; retrieves these values with the &lt;code&gt;import&lt;/code&gt; task:&lt;br /&gt;


&lt;pre&gt;&amp;lt;import file=&quot;${ANTPROPERTIES}&quot;/&amp;gt;&lt;/pre&gt;
The &lt;code&gt;transaction&lt;/code&gt; element specifies a file that contains SQL statements to execute. The file &lt;code&gt;create-tables.sql&lt;/code&gt; contains two SQL statements that create the &lt;code&gt;SUPPLIERS&lt;/code&gt; and &lt;code&gt;COFFEES&lt;/code&gt; tables:&lt;br /&gt;


&lt;pre&gt;create table SUPPLIERS
  (SUP_ID integer NOT NULL,
  SUP_NAME varchar(40) NOT NULL,
  STREET varchar(40) NOT NULL,
  CITY varchar(20) NOT NULL,
  STATE char(2) NOT NULL,
  ZIP char(5),
  PRIMARY KEY (SUP_ID));

create table COFFEES
  (COF_NAME varchar(32) NOT NULL,
  SUP_ID int NOT NULL,
  PRICE numeric(10,2) NOT NULL,
  SALES integer NOT NULL,
  TOTAL integer NOT NULL,
  PRIMARY KEY (COF_NAME),
  FOREIGN KEY (SUP_ID) REFERENCES SUPPLIERS (SUP_ID));&lt;/pre&gt;
&lt;strong&gt;Note&lt;/strong&gt;: The file &lt;code&gt;build.xml&lt;/code&gt; contains another target named &lt;code&gt;drop-tables&lt;/code&gt; that deletes the &lt;code&gt;SUPPLIERS&lt;/code&gt; and &lt;code&gt;COFFEES&lt;/code&gt; tables; run this target if you want to re-create these tables.&lt;br /&gt;


&lt;h4&gt;
Creating Tables with JDBC API&lt;/h4&gt;
The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;SuppliersTable.createTable&lt;/a&gt;&lt;/code&gt;, creates the &lt;code&gt;SUPPLIERS&lt;/code&gt; table:&lt;br /&gt;


&lt;pre&gt;  public void createTable() throws SQLException {
    String createString = &quot;create table &quot; + dbName + &quot;.SUPPLIERS &quot; +
      &quot;(SUP_ID integer NOT NULL, &quot; +
      &quot;SUP_NAME varchar(40) NOT NULL, &quot; +
      &quot;STREET varchar(40) NOT NULL, &quot; +
      &quot;CITY varchar(20) NOT NULL, &quot; +
      &quot;STATE char(2) NOT NULL, &quot; +
            &quot;ZIP char(5), &quot; +
            &quot;PRIMARY KEY (SUP_ID))&quot;;
    Statement stmt = null;
    try {
      stmt = con.createStatement();
      stmt.executeUpdate(createString);
    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      stmt.close();
    }
  }&lt;/pre&gt;
The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;CoffeesTable.createTable&lt;/a&gt;&lt;/code&gt;, creates the &lt;code&gt;COFFEES&lt;/code&gt; table:&lt;br /&gt;


&lt;pre&gt;  public void createTable() throws SQLException {
    String createString = &quot;create table &quot; + dbName + &quot;.COFFEES &quot; +
              &quot;(COF_NAME varchar(32) NOT NULL, &quot; +
              &quot;SUP_ID int NOT NULL, &quot; +
              &quot;PRICE float NOT NULL, &quot; +
              &quot;SALES integer NOT NULL, &quot; +
              &quot;TOTAL integer NOT NULL, &quot; +
              &quot;PRIMARY KEY (COF_NAME), &quot; +
              &quot;FOREIGN KEY (SUP_ID) REFERENCES &quot; + dbName + &quot;.SUPPLIERS (SUP_ID))&quot;;
    Statement stmt = null;
    try {
      stmt = con.createStatement();
      stmt.executeUpdate(createString);
    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      stmt.close();
    }
  }&lt;/pre&gt;
In both methods, &lt;code&gt;con&lt;/code&gt; is a &lt;code&gt;Connection&lt;/code&gt; object and &lt;code&gt;dbName&lt;/code&gt; is the name of the database in which you are creating the table.&lt;br /&gt;


To execute the SQL query, such as those specified by the &lt;code&gt;String&lt;/code&gt; &lt;code&gt;createString&lt;/code&gt;, use a &lt;code&gt;Statement&lt;/code&gt; object. To create a &lt;code&gt;Statement&lt;/code&gt; object, call the method &lt;code&gt;Connection.createStatement&lt;/code&gt; from an existing &lt;code&gt;Connection&lt;/code&gt; object. To execute an SQL query, call the method &lt;code&gt;Statement.executeUpdate&lt;/code&gt;.

&lt;br /&gt;
All &lt;code&gt;Statement&lt;/code&gt; objects are closed when the connection that created them is closed. However, it is good coding practice to explicitly close &lt;code&gt;Statement&lt;/code&gt;
 objects as soon as you are finished with them. This allows any external
 resources that the statement is using to be released immediately. Close
 a statement by calling the method &lt;code&gt;Statement.close&lt;/code&gt;. Place this statement in a &lt;code&gt;finally&lt;/code&gt; to ensure that it closes even if the normal program flow is interrupted because an exception (such as &lt;code&gt;SQLException&lt;/code&gt;) is thrown.&lt;br /&gt;


&lt;strong&gt;Note&lt;/strong&gt;: You must create the &lt;code&gt;SUPPLIERS&lt;/code&gt; table before the &lt;code&gt;COFFEES&lt;/code&gt; because &lt;code&gt;COFFEES&lt;/code&gt; contains a foreign key, &lt;code&gt;SUP_ID&lt;/code&gt; that references &lt;code&gt;SUPPLIERS&lt;/code&gt;.&lt;br /&gt;


&lt;h3&gt;
Populating Tables&lt;/h3&gt;
Similarly, you can insert data into tables with Apache Ant or JDBC API.&lt;br /&gt;


&lt;h4&gt;
Populating Tables with Apache Ant&lt;/h4&gt;
To populate the &lt;code&gt;SUPPLIERS&lt;/code&gt; and &lt;code&gt;COFFEES&lt;/code&gt; tables with the tutorial sample code, run the following command (at a command prompt) in the directory &lt;code&gt;&lt;em&gt;&amp;lt;JDBC tutorial directory&amp;gt;&lt;/em&gt;&lt;/code&gt;:

&lt;code&gt;ant populate-tables&lt;/code&gt;

&lt;br /&gt;
This Ant target executes the SQL statements in the file &lt;code&gt;populate-tables.sql&lt;/code&gt;:&lt;br /&gt;


&lt;pre&gt;insert into SUPPLIERS values(49, &#39;Superior Coffee&#39;, &#39;1 Party Place&#39;, &#39;Mendocino&#39;, &#39;CA&#39;, &#39;95460&#39;);
insert into SUPPLIERS values(101, &#39;Acme, Inc.&#39;, &#39;99 Market Street&#39;, &#39;Groundsville&#39;, &#39;CA&#39;, &#39;95199&#39;);
insert into SUPPLIERS values(150, &#39;The High Ground&#39;, &#39;100 Coffee Lane&#39;, &#39;Meadows&#39;, &#39;CA&#39;, &#39;93966&#39;);
insert into COFFEES values(&#39;Colombian&#39;, 00101, 7.99, 0, 0);
insert into COFFEES values(&#39;French_Roast&#39;, 00049, 8.99, 0, 0);
insert into COFFEES values(&#39;Espresso&#39;, 00150, 9.99, 0, 0);
insert into COFFEES values(&#39;Colombian_Decaf&#39;, 00101, 8.99, 0, 0);
insert into COFFEES values(&#39;French_Roast_Decaf&#39;, 00049, 9.99, 0, 0);&lt;/pre&gt;
&lt;h4&gt;
Populating Tables with JDBC API&lt;/h4&gt;
The following method, &lt;code&gt;SuppliersTable.populateTable&lt;/code&gt;, inserts data into the table:&lt;br /&gt;


&lt;pre&gt;  public void populateTable() throws SQLException {
    Statement stmt = null;
    try {
      stmt = con.createStatement();
      stmt.executeUpdate(&quot;insert into &quot; + dbName + &quot;.SUPPLIERS &quot; +
                         &quot;values(49, &#39;Superior Coffee&#39;, &#39;1 Party Place&#39;, &quot; +
                         &quot;&#39;Mendocino&#39;, &#39;CA&#39;, &#39;95460&#39;)&quot;);
      stmt.executeUpdate(&quot;insert into &quot; + dbName + &quot;.SUPPLIERS &quot; +
                          &quot;values(101, &#39;Acme, Inc.&#39;, &#39;99 Market Street&#39;, &quot; +
                          &quot;&#39;Groundsville&#39;, &#39;CA&#39;, &#39;95199&#39;)&quot;);
      stmt.executeUpdate(&quot;insert into &quot; + dbName + &quot;.SUPPLIERS &quot; +
                         &quot;values(150, &#39;The High Ground&#39;, &#39;100 Coffee Lane&#39;, &quot; +
                         &quot;&#39;Meadows&#39;, &#39;CA&#39;, &#39;93966&#39;)&quot;);
    } catch (SQLException e) {
      JDBCTutorialUtilities.printSQLException(e);
    } finally {
      stmt.close();
    }
  }&lt;/pre&gt;
The following method, &lt;code&gt;CoffeesTable.populateTable&lt;/code&gt;, inserts data into the table:&lt;br /&gt;


&lt;pre&gt;  public void populateTable() throws SQLException {
    Statement stmt = null;
    try {
      stmt = con.createStatement();
      stmt.executeUpdate(&quot;insert into &quot; + dbName + &quot;.COFFEES &quot; +
             &quot;values(&#39;Colombian&#39;, 00101, 7.99, 0, 0)&quot;);
      stmt.executeUpdate(&quot;insert into &quot; + dbName + &quot;.COFFEES &quot; +
             &quot;values(&#39;French_Roast&#39;, 00049, 8.99, 0, 0)&quot;);
      stmt.executeUpdate(&quot;insert into &quot; + dbName + &quot;.COFFEES &quot; +
             &quot;values(&#39;Espresso&#39;, 00150, 9.99, 0, 0)&quot;);
      stmt.executeUpdate(&quot;insert into &quot; + dbName + &quot;.COFFEES &quot; +
             &quot;values(&#39;Colombian_Decaf&#39;, 00101, 8.99, 0, 0)&quot;);
      stmt.executeUpdate(&quot;insert into &quot; + dbName + &quot;.COFFEES &quot; +
             &quot;values(&#39;French_Roast_Decaf&#39;, 00049, 9.99, 0, 0)&quot;);
      } catch (SQLException e) {
        JDBCTutorialUtilities.printSQLException(e);
      } finally {
        stmt.close();
      }&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/4250595349778652666/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcsetting-up-tables.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/4250595349778652666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/4250595349778652666'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcsetting-up-tables.html' title='JDBC:Setting Up Tables'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-3067197508409619540</id><published>2011-01-15T12:45:00.000-08:00</published><updated>2011-01-15T12:45:08.534-08:00</updated><title type='text'>JDBC:Handling SQLExceptions</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
Handling SQLExceptions&lt;/div&gt;
&lt;blockquote&gt;

When JDBC encounters an error during an interaction with a data source, it throws an instance of &lt;code&gt;SQLException&lt;/code&gt; as opposed to &lt;code&gt;Exception&lt;/code&gt;. (A data source in this context represents the database to which a &lt;code&gt;Connection&lt;/code&gt; object is connected.) The &lt;code&gt;SQLException&lt;/code&gt; instance contains the following information that can help you determine the cause of the error:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;A description of the error. Retrieve the &lt;code&gt;String&lt;/code&gt; object that contains this description by calling the method &lt;code&gt;SQLException.getMessage&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A SQLState code. These codes and their respective meanings have
 been standardized by ISO/ANSI and Open Group (X/Open), although some 
codes have been reserved for database vendors to define for themselves. 
This &lt;code&gt;String&lt;/code&gt; object consists of five alphanumeric characters. Retrieve this code by calling the method &lt;code&gt;SQLException.getSQLState&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;An error code. This is an integer value identifying the error that caused the &lt;code&gt;SQLException&lt;/code&gt;
 instance to be thrown. Its value and meaning are 
implementation-specific and might be the actual error code returned by 
the underlying data source. Retrieve the error by calling the method &lt;code&gt;SQLException.getErrorCode&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A cause. A &lt;code&gt;SQLException&lt;/code&gt; instance might have a causal relationship, which consists of one or more &lt;code&gt;Throwable&lt;/code&gt; objects that caused the &lt;code&gt;SQLException&lt;/code&gt; instance to be thrown. To navigate this chain of causes, recursively call the method &lt;code&gt;SQLException.getCause&lt;/code&gt; until a &lt;code&gt;null&lt;/code&gt; value is returned.&lt;/li&gt;
&lt;li&gt;A reference to any &lt;em&gt;chained&lt;/em&gt; exceptions. If more than 
one error occurs, the exceptions are referenced through this chain. 
Retrieve these exceptions by calling the method &lt;code&gt;SQLException.getNextException&lt;/code&gt; on the exception that was thrown.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
Retrieving Exceptions&lt;/h3&gt;
The following method, &lt;code&gt;JDBCTutorialUtilities.printSQLException&lt;/code&gt; outputs the SQLState, error code, error description, and cause (if there is one) contained in the &lt;code&gt;SQLException&lt;/code&gt; as well as any other exception chained to it:&lt;br /&gt;


&lt;pre&gt;  public static void printSQLException(SQLException ex) {
    for (Throwable e : ex) {
      if (e instanceof SQLException) {
        &lt;strong&gt;if (ignoreSQLException(((SQLException)e).getSQLState()) == false)&lt;/strong&gt; {
          e.printStackTrace(System.err);
          System.err.println(&quot;SQLState: &quot; + ((SQLException)e).getSQLState());
          System.err.println(&quot;Error Code: &quot; + ((SQLException)e).getErrorCode());
          System.err.println(&quot;Message: &quot; + ((SQLException)e).getMessage());
          Throwable t = ex.getCause();
          while(t != null) {
              System.out.println(&quot;Cause: &quot; + t);
              t = t.getCause();
          }
        }
      }
    }
  }&lt;/pre&gt;
For example, if you call the method &lt;code&gt;CoffeesTable.dropTable&lt;/code&gt; with Java DB as your DBMS, the table &lt;code&gt;COFFEES&lt;/code&gt; does not exist, &lt;em&gt;and&lt;/em&gt; you remove the call to &lt;code&gt;JDBCTutorialUtilities.ignoreSQLException&lt;/code&gt;, the output will be similar to the following:&lt;br /&gt;


&lt;pre&gt;SQLState: 42Y55
Error Code: 30000
Message: &#39;DROP TABLE&#39; cannot be performed on &#39;TESTDB.COFFEES&#39; because it does not exist.&lt;/pre&gt;
Instead of outputting &lt;code&gt;SQLException&lt;/code&gt; information, you could instead first retrieve the &lt;code&gt;SQLState&lt;/code&gt; then process the &lt;code&gt;SQLException&lt;/code&gt; accordingly. For example, the method &lt;code&gt;JDBCTutorialUtilities.ignoreSQLException&lt;/code&gt; returns &lt;code&gt;true&lt;/code&gt; if the SQLState&amp;gt; is equal to code &lt;code&gt;42Y55&lt;/code&gt; (and you are using Java DB as your DBMS), which causes &lt;code&gt;JDBCTutorialUtilities.printSQLException&lt;/code&gt; to ignore the &lt;code&gt;SQLException&lt;/code&gt;:&lt;br /&gt;


&lt;pre&gt;  public static boolean ignoreSQLException(String sqlState) {
    // X0Y32: Jar file already exists in schema
    if (sqlState.equalsIgnoreCase(&quot;X0Y32&quot;)) return true;
    // 42Y55: Table already exists in schema
    if (sqlState.equalsIgnoreCase(&quot;42Y55&quot;)) return true;
    return false;
  }&lt;/pre&gt;
&lt;h3&gt;
Retrieving Warnings&lt;/h3&gt;
&lt;code&gt;SQLWarning&lt;/code&gt; objects are a subclass of &lt;code&gt;SQLException&lt;/code&gt;
 that deal with database access warnings. Warnings do not stop the 
execution of an application, as exceptions do; they simply alert the 
user that something did not happen as planned. For example, a warning 
might let you know that a privilege you attempted to revoke was not 
revoked. Or a warning might tell you that an error occurred during a 
requested disconnection.&lt;br /&gt;


A warning can be reported on a &lt;code&gt;Connection&lt;/code&gt; object, a &lt;code&gt;Statement&lt;/code&gt; object (including &lt;code&gt;PreparedStatement&lt;/code&gt; and &lt;code&gt;CallableStatement&lt;/code&gt; objects), or a &lt;code&gt;ResultSet&lt;/code&gt; object. Each of these classes has a &lt;code&gt;getWarnings&lt;/code&gt; method, which you must invoke in order to see the first warning reported on the calling object. If &lt;code&gt;getWarnings&lt;/code&gt; returns a warning, you can call the &lt;code&gt;SQLWarning&lt;/code&gt; method &lt;code&gt;
getNextWarning&lt;/code&gt; on it to get any additional warnings. Executing a 
statement automatically clears the warnings from a previous statement, 
so they do not build up. This means, however, that if you want to 
retrieve warnings reported on a statement, you must do so before you 
execute another statement.&lt;br /&gt;


The following methods from &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;JDBCTutorialUtilities&lt;/a&gt;&lt;/code&gt; illustrate how to get complete information about any warnings reported on &lt;code&gt;Statement&lt;/code&gt; or &lt;code&gt;ResultSet&lt;/code&gt; objects:&lt;br /&gt;


&lt;pre&gt;  public static void getWarningsFromResultSet(ResultSet rs) throws SQLException {
    JDBCTutorialUtilities.printWarnings(rs.getWarnings());
  }

  public static void getWarningsFromStatement(Statement stmt) throws SQLException {
    JDBCTutorialUtilities.printWarnings(stmt.getWarnings());
  }

  public static void printWarnings(SQLWarning warning) throws SQLException {
    if (warning != null) {
      System.out.println(&quot;\n---Warning---\n&quot;);
      while (warning != null) {
        System.out.println(&quot;Message: &quot; + warning.getMessage());
        System.out.println(&quot;SQLState: &quot; + warning.getSQLState());
        System.out.print(&quot;Vendor error code: &quot;);
        System.out.println(warning.getErrorCode());
        System.out.println(&quot;&quot;);
        warning = warning.getNextWarning();
      }
    }
  }&lt;/pre&gt;
The most common warning is a &lt;code&gt;DataTruncation&lt;/code&gt; warning, a subclass of &lt;code&gt;SQLWarning&lt;/code&gt;. All &lt;code&gt;DataTruncation&lt;/code&gt;
 objects have a SQLState of &lt;code&gt;01004&lt;/code&gt;, indicating that there was a problem with reading or writing data. &lt;code&gt;DataTruncation&lt;/code&gt;
 methods let you find out in which column or parameter data was 
truncated, whether the truncation was on a read or write operation, how 
many bytes should have been transferred, and how many bytes were 
actually transferred.&lt;br /&gt;


&lt;h3&gt;
Categorized SQLExceptions&lt;/h3&gt;
Your JDBC driver might throw a subclass of &lt;code&gt;SQLException&lt;/code&gt; 
that corresponds to a common SQLState or a common error state that is 
not associated with a specific SQLState class value. This enables you to
 write more portable error-handling code. These exceptions are 
subclasses of one of the following classes:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;SQLNonTransientException&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SQLTransientException&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SQLRecoverableException&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
See the latest Javadoc of the &lt;code&gt;java.sql&lt;/code&gt; package or the documentation of your JDBC driver for more information about these subclasses.&lt;br /&gt;


&lt;h3&gt;
Other Subclasses of SQLException&lt;/h3&gt;
The following subclasses of &lt;code&gt;SQLException&lt;/code&gt; can also be thrown:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;BatchUpdateException&lt;/code&gt; is thrown when an error occurs during a batch update operation. In addition to the information provided by &lt;code&gt;SQLException&lt;/code&gt;, &lt;code&gt;BatchUpdateException&lt;/code&gt; provides the update counts for all statements that were executed before the error occurred.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SQLClientInfoException&lt;/code&gt; is thrown when one or more 
client information properties could not be set on a Connection. In 
addition to the information provided by &lt;code&gt;SQLException&lt;/code&gt;, &lt;code&gt;SQLClientInfoException&lt;/code&gt; provides a list of client information properties that were not set.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/3067197508409619540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbchandling-sqlexceptions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3067197508409619540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3067197508409619540'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbchandling-sqlexceptions.html' title='JDBC:Handling SQLExceptions'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-3320002981995542753</id><published>2011-01-15T12:42:00.001-08:00</published><updated>2011-01-15T12:42:47.697-08:00</updated><title type='text'>JDBC:Establishing a Connection</title><content type='html'>&lt;div id=&quot;PageTitle&quot;&gt;
Establishing a Connection&lt;/div&gt;
First, you need to establish a connection with the data source you 
want to use. A data source can be a DBMS, a legacy file system, or some 
other source of data with a corresponding JDBC driver. Typically, a JDBC
 application connects to a target data source using one of two classes:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;DriverManager&lt;/code&gt;: This fully implemented class connects
 an application to a data source, which is specified by a database URL. 
When this class first attempts to establish a connection, it 
automatically loads any JDBC 4.0 drivers found within the class path. 
Note that your application must manually load any JDBC drivers prior to 
version 4.0.&lt;br /&gt;


&lt;/li&gt;
&lt;li&gt;&lt;code&gt;DataSource&lt;/code&gt;: This interface is preferred over &lt;code&gt;DriverManager&lt;/code&gt; because it allows details about the underlying data source to be transparent to your application. A &lt;code&gt;DataSource&lt;/code&gt; object&#39;s properties are set so that it represents a particular data source.&lt;/li&gt;
&lt;/ul&gt;
&lt;strong&gt;Note&lt;/strong&gt;: The samples in this tutorial use the &lt;code&gt;DriverManager&lt;/code&gt; class instead of the &lt;code&gt;DataSource&lt;/code&gt; class because it is easier to use and the samples do not require the features of the &lt;code&gt;DataSource&lt;/code&gt; class.&lt;br /&gt;





&lt;h3&gt;
Using the DriverManager Class&lt;/h3&gt;
Connecting to your DBMS with the &lt;code&gt;DriverManager&lt;/code&gt; class involves calling the method &lt;code&gt;DriverManager.getConnection&lt;/code&gt;. The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;JDBCTutorialUtilities.getConnection&lt;/a&gt;&lt;/code&gt;, establishes a database connection:&lt;br /&gt;


&lt;pre&gt;  public Connection getConnection() throws SQLException {
    Connection conn = null;
    Properties connectionProps = new Properties();
    connectionProps.put(&quot;user&quot;, this.userName);
    connectionProps.put(&quot;password&quot;, this.password);

    if (this.dbms.equals(&quot;mysql&quot;)) {
      conn = DriverManager.
        getConnection(&quot;jdbc:&quot; + this.dbms + &quot;://&quot; + this.serverName +
                      &quot;:&quot; + this.portNumber + &quot;/&quot;, connectionProps);
    } else if (this.dbms.equals(&quot;derby&quot;)) {
      conn = DriverManager.
        getConnection(&quot;jdbc:&quot; + this.dbms + &quot;:&quot; + this.dbName + &quot;;create=true&quot;, connectionProps);
    }
    System.out.println(&quot;Connected to database&quot;);
    return conn;
  }&lt;/pre&gt;
The method &lt;code&gt;DriverManager.getConnection&lt;/code&gt; establishes a 
database connection. This method requires a database URL, which varies 
depending on your DBMS. The following are some examples of database 
URLs:&lt;br /&gt;


&lt;ol&gt;
&lt;li&gt;MySQL: &lt;code&gt;jdbc:mysql://localhost:3306/&lt;/code&gt;, where &lt;code&gt;localhost&lt;/code&gt; is the name of the server hosting your database, and &lt;code&gt;3306&lt;/code&gt; is the port number&lt;/li&gt;
&lt;li&gt;Java DB: &lt;code&gt;jdbc:derby:&lt;em&gt;testdb&lt;/em&gt;;create=true&lt;/code&gt;, where &lt;code&gt;&lt;em&gt;testdb&lt;/em&gt;&lt;/code&gt; is the name of the database to connect to, and &lt;code&gt;create=true&lt;/code&gt; instructs the DBMS to create the database.&lt;br /&gt;

  &lt;strong&gt;Note&lt;/strong&gt;: This URL establishes a database connection 
with the Java DB Embedded Driver. Java DB also includes a Network Client
 Driver, which uses a different URL.&lt;br /&gt;

  &lt;/li&gt;
&lt;/ol&gt;
This method specifies the user name and password required to access the DBMS with a &lt;code&gt;Properties&lt;/code&gt; object.&lt;br /&gt;


&lt;strong&gt;Note&lt;/strong&gt;:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;Typically, in the database URL, you also specify the name of an
 existing database to which you want to connect. For example, the URL &lt;code&gt;jdbc:mysql://localhost:3306/mysql&lt;/code&gt; represents the database URL for the MySQL database named &lt;code&gt;mysql&lt;/code&gt;. The samples in this tutorial use a URL that does not specify a specific database because the samples create a new database.&lt;/li&gt;
&lt;li&gt;In previous versions of JDBC, to obtain a connection, you first had to initialize your JDBC driver by calling the method &lt;code&gt;Class.forName&lt;/code&gt; or &lt;code&gt;DriverManager.registerDriver&lt;/code&gt;. These methods required an object of type &lt;code&gt;java.sql.Driver&lt;/code&gt;. Each JDBC driver contains one or more classes that implements the interface &lt;code&gt;java.sql.Driver&lt;/code&gt;. The drivers for Java DB are &lt;code&gt;org.apache.derby.jdbc.EmbeddedDriver&lt;/code&gt; and &lt;code&gt;org.apache.derby.jdbc.ClientDriver&lt;/code&gt;, and the one for MySQL Connector/J is &lt;code&gt;com.mysql.jdbc.Driver&lt;/code&gt;. See the documentation of your DBMS driver to obtain the name of the class that implements the interface &lt;code&gt;java.sql.Driver&lt;/code&gt;.&lt;br /&gt;


  Any JDBC 4.0 drivers that are found in your class path are 
automatically loaded. (However, you must manually load any drivers prior
 to JDBC 4.0 with one of these initialization methods.)&lt;/li&gt;
&lt;/ul&gt;
The method returns a &lt;code&gt;Connection&lt;/code&gt; object, which represents a connection with the DBMS or a specific database. Query the database through this object.&lt;br /&gt;




&lt;h3&gt;
Specifying Database Connection URLs&lt;/h3&gt;
A database connection URL is a string that your DBMS JDBC driver uses
 to connect to a database. It can contain information such as where to 
search for the database, the name of the database to connect to, and 
configuration properties. The exact syntax of a database connection URL 
is specified by your DBMS.&lt;br /&gt;


&lt;h4&gt;
Java DB Database Connection URLs&lt;/h4&gt;
The following is the database connection URL syntax for Java DB:&lt;br /&gt;


&lt;pre&gt;jdbc:derby:[&lt;em&gt;subsubprotocol&lt;/em&gt;:][&lt;em&gt;databaseName&lt;/em&gt;][;&lt;em&gt;attribute&lt;/em&gt;=&lt;em&gt;value&lt;/em&gt;]*&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&lt;em&gt;subsubprotocol&lt;/em&gt;&lt;/code&gt; specifies where Java DB 
should search for the database, either in a directory, in memory, in a 
class path, or in a JAR file. It is typically omitted.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&lt;em&gt;databaseName&lt;/em&gt;&lt;/code&gt; is the name of the database to connect to.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&lt;em&gt;attribute&lt;/em&gt;=&lt;em&gt;value&lt;/em&gt;&lt;/code&gt; represents an 
optional, semicolon-separated list of attributes. These attributes 
enable you to instruct Java DB to perform various tasks, including the 
following:
    &lt;ul&gt;
&lt;li&gt;Create the database specified in the connection URL.&lt;/li&gt;
&lt;li&gt;Encrypt the database specified in the connection URL.&lt;/li&gt;
&lt;li&gt;Specify directories to store logging and trace information.&lt;/li&gt;
&lt;li&gt;Specify a user name and password to connect to the database.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
See &lt;em&gt;Java DB Developer&#39;s Guide&lt;/em&gt; and &lt;em&gt;Java DB Reference Manual&lt;/em&gt; for more information.&lt;br /&gt;


&lt;h4&gt;
MySQL Connector/J Database URL&lt;/h4&gt;
The following is the database connection URL syntax for MySQL Connector/J:&lt;br /&gt;


&lt;pre&gt;jdbc:mysql://[&lt;em&gt;host&lt;/em&gt;][,&lt;em&gt;failoverhost&lt;/em&gt;...][:&lt;em&gt;port&lt;/em&gt;]/[&lt;em&gt;database&lt;/em&gt;][?&lt;em&gt;propertyName1&lt;/em&gt;][=&lt;em&gt;propertyValue1&lt;/em&gt;][&amp;amp;&lt;em&gt;propertyName2&lt;/em&gt;][=&lt;em&gt;propertyValue2&lt;/em&gt;]...&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&lt;em&gt;host&lt;/em&gt;:&lt;em&gt;port&lt;/em&gt;&lt;/code&gt; is the host name and port number of the computer hosting your database. If not specified, the default values of &lt;code&gt;&lt;em&gt;host&lt;/em&gt;&lt;/code&gt; and &lt;code&gt;&lt;em&gt;port&lt;/em&gt;&lt;/code&gt; are 127.0.0.1 and 3306, respectively.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&lt;em&gt;database&lt;/em&gt;&lt;/code&gt; is the name of the database to connect to. If not specified, a connection is made with no default database.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&lt;em&gt;failover&lt;/em&gt;&lt;/code&gt; is the name of a standby database (MySQL Connector/J supports failover).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&lt;em&gt;propertyName&lt;/em&gt;=&lt;em&gt;propertyValue&lt;/em&gt;&lt;/code&gt; 
represents an optional, ampersand-separated list of properties. These 
attributes enable you to instruct MySQL Connector/J to perform various 
tasks.&lt;/li&gt;
&lt;/ul&gt;
See &lt;em&gt;MySQL Reference Manual&lt;/em&gt; for more information.&lt;br /&gt;





&lt;h3&gt;
Using a DataSource Object for a Connection&lt;/h3&gt;
A &lt;code&gt;DataSource&lt;/code&gt; object represents a particular DBMS or some other data source, such as a file. The following method, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html&quot;&gt;JDBCTutorialUtilities.getConnectionWithDataSource&lt;/a&gt;&lt;/code&gt;, creates a &lt;code&gt;DataSource&lt;/code&gt; object, then creates a &lt;code&gt;Connection&lt;/code&gt; object, which represents a database connection with the &lt;code&gt;DataSource&lt;/code&gt; object:&lt;br /&gt;


&lt;pre&gt;  public Connection getConnectionWithDataSource(String dbmsName, String dbNameArg, String userName, String password, String serverName, int portNumber) throws SQLException {
    Connection conn = null;

    if (dbmsName.equals(&quot;mysql&quot;)) {
      com.mysql.jdbc.jdbc2.optional.MysqlDataSource ds = null;
      ds = new com.mysql.jdbc.jdbc2.optional.MysqlDataSource();
      ds.setUser(userName);
      ds.setPassword(password);
      ds.setServerName(serverName);
      ds.setPortNumber(portNumber);
      conn = ds.getConnection();
    } else if (dbmsName.equals(&quot;derby&quot;)) {
      org.apache.derby.jdbc.EmbeddedDataSource ds = null;
      ds = new org.apache.derby.jdbc.EmbeddedDataSource();
      ds.setDatabaseName(dbNameArg);
      ds.setUser(userName);
      ds.setPassword(password);
      conn = ds.getConnection();
    }
    System.out.println(&quot;Connected to database&quot;);
    return conn;
  }&lt;/pre&gt;
Each DBMS driver contains a class that implements the interface &lt;code&gt;java.sql.DataSource&lt;/code&gt;. MySQL Connector/J implements it with the class &lt;code&gt;com.mysql.jdbc.jdbc2.optional.MysqlDataSource&lt;/code&gt;. Java DB has several classes that can create &lt;code&gt;DataSource&lt;/code&gt; objects including the following:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;code&gt;org.apache.derby.jdbc.EmbeddedDataSource&lt;/code&gt;: Use this class if Java DB is running in the same Java Virtual Machine as your application.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;org.apache.derby.jdbc.ClientDriver&lt;/code&gt;: Use this class if your application access Java DB from an external server.&lt;/li&gt;
&lt;/ul&gt;
Unlike a &lt;code&gt;DriverManager&lt;/code&gt; object, you can configure a &lt;code&gt;DataSource&lt;/code&gt;
 object by setting any of its various properties, such as the database&#39;s
 server name and port number. Consequently, you do not have to code the 
driver name or the JDBC URL into your applications. This makes your 
application code more portable.&lt;br /&gt;


Typically, using a tool that comes with an application server, a system administrator creates and configures a &lt;code&gt;DataSource&lt;/code&gt;
 object, then registers it with a naming service that uses the Java 
Naming and Directory Interface (JNDI) API. JNDI enables applications 
based on Java technology to store and retrieve named Java objects of any
 type. Consequently, a developer can use JNDI to retrieve the 
pre-configured &lt;code&gt;DataSource&lt;/code&gt; object that the system administrator created.&lt;br /&gt;




For more information about developing applications with the &lt;code&gt;DataSource&lt;/code&gt; class,</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/3320002981995542753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcestablishing-connection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3320002981995542753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3320002981995542753'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcestablishing-connection.html' title='JDBC:Establishing a Connection'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-3463363850589609099</id><published>2011-01-15T12:41:00.000-08:00</published><updated>2011-01-15T12:41:35.217-08:00</updated><title type='text'>JDBC:Getting Started</title><content type='html'>&lt;blockquote&gt;

The sample code that comes with this tutorial creates a database that
 is used by a proprietor of a small coffee house called The Coffee 
Break, where coffee beans are sold by the pound and brewed coffee is 
sold by the cup. To keep things simple, the proprietor needs only two 
tables, one for types of coffee and one for coffee suppliers.&lt;br /&gt;


The following steps configure a JDBC development environment with which you can compile and run the tutorial samples:&lt;br /&gt;


&lt;ol&gt;
&lt;li&gt;Install the latest version of the Java SE SDK on your computer. &lt;/li&gt;
&lt;li&gt;Install your database management system (DBMS) if needed.&lt;br /&gt;

You may use Java DB, which comes with the latest version of Java SE SDK. This tutorial has been tested for the following DBMS:&lt;br /&gt;


&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://developers.sun.com/javadb/&quot;&gt;Java DB&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.mysql.com/&quot;&gt;MySQL&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
Note that if you are using another DBMS, you might have to alter the code of the tutorial samples.&lt;br /&gt;

&lt;/li&gt;
&lt;li&gt;Install a JDBC driver from the vendor of your database.&lt;br /&gt;


If you are using Java DB, it already comes with a JDBC driver. If you are using MySQL, install the latest version of &lt;a href=&quot;http://www.mysql.com/products/connector/&quot;&gt;Connector/J&lt;/a&gt;.&lt;br /&gt;


To obtain a JDBC driver for a particular DBMS, refer to &lt;a href=&quot;http://developers.sun.com/product/jdbc/drivers&quot;&gt;JDBC Data Access API&lt;/a&gt;.&lt;br /&gt;


There are many possible implementations of JDBC drivers. These implementations are categorized as follows:&lt;br /&gt;


  &lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Type 1&lt;/strong&gt;: Drivers that implement the JDBC API as a
 mapping to another data access API, such as ODBC (Open Database 
Connectivity). Drivers of this type are generally dependent on a native 
library, which limits their portability. The JDBC-ODBC Bridge driver is 
an example of a Type 1 driver.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Type 2&lt;/strong&gt;: Drivers that are written partly in the 
Java programming language and partly in native code. These drivers use a
 native client library specific to the data source to which they 
connect. Again, because of the native code, their portability is 
limited. Oracle&#39;s OCI (Oracle Call Interface) client-side driver is an 
example of a Type 2 driver.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Type 3&lt;/strong&gt;: Drivers that use a pure Java client and
 communicate with a middleware server using a database-independent 
protocol. The middleware server then communicates the client&#39;s requests 
to the data source.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Type 4&lt;/strong&gt;: Drivers that are pure Java and 
implement the network protocol for a specific data source. The client 
connects directly to the data source.&lt;/li&gt;
&lt;/ul&gt;
Check which driver type comes with your DBMS. Java DB comes with two 
Type 4 drivers, an Embedded driver and a Network Client Driver. MySQL 
Connector/J is a Type 4 driver.&lt;br /&gt;


Installing a JDBC driver generally consists of copying the driver to 
your computer, then adding the location of it to your class path. In 
addition, many JDBC drivers other than Type 4 drivers require you to 
install a client-side API. No other special configuration is usually 
needed.&lt;br /&gt;


&lt;/li&gt;
&lt;li&gt;Install Apache Ant.&lt;br /&gt;


These steps use Apache Ant, a Java-based tool, to build, compile, and
 run the JDBC tutorial samples. Go to the following link to download 
Apache Ant:&lt;br /&gt;


&lt;code&gt;&lt;a href=&quot;http://ant.apache.org/&quot;&gt;http://ant.apache.org/&lt;/a&gt;&lt;/code&gt;&lt;br /&gt;


Ensure that the Apache Ant executable file is in your &lt;code&gt;PATH&lt;/code&gt; environment variable so that you can run it from any directory.&lt;br /&gt;


&lt;/li&gt;
&lt;li&gt;Download the sample code.&lt;br /&gt;


The sample code, &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/examples/zipfiles/JDBCTutorial.zip&quot;&gt;JDBCTutorial.zip&lt;/a&gt;&lt;/code&gt;, consists of the following files:&lt;br /&gt;



&lt;ul&gt;
&lt;li&gt;&lt;code&gt;properties&lt;/code&gt;
    &lt;ul&gt;
&lt;li&gt;&lt;code&gt;javadb-build-properties.xml&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;javadb-sample-properties.xml&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;mysql-build-properties.xml&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;mysql-sample-properties.xml&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sql&lt;/code&gt;
    &lt;ul&gt;
&lt;li&gt;&lt;code&gt;javadb&lt;/code&gt;
        &lt;ul&gt;
&lt;li&gt;&lt;code&gt;create-procedure-show-suppliers.sql&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;create-tables.sql&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;drop-tables.sql&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;populate-tables.sql&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;mysql&lt;/code&gt;
        &lt;ul&gt;
&lt;li&gt;&lt;code&gt;create-procedure-show-suppliers.sql&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;create-tables.sql&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;drop-tables.sql&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;populate-tables.sql&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;src/com/oracle/tutorial/jdbc&lt;/code&gt;
    &lt;ul&gt;
&lt;li&gt;&lt;code&gt;CoffeesTable.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;JDBCTutorialUtilities.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;JoinSample.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;StoredProcedureJavaDBSample.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;StoredProcedureMySQLSample.java&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SuppliersTable.java&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;build.xml&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
Create a directory to contain all the files of the sample. These steps refer to this directory as &lt;code&gt;&lt;em&gt;&amp;lt;JDBC tutorial directory&amp;gt;&lt;/em&gt;&lt;/code&gt;. Unzip the contents of &lt;code&gt;&lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/examples/zipfiles/JDBCTutorial.zip&quot;&gt;JDBCTutorial.zip&lt;/a&gt;&lt;/code&gt; into &lt;code&gt;&lt;em&gt;&amp;lt;JDBC tutorial directory&amp;gt;&lt;/em&gt;&lt;/code&gt;.&lt;br /&gt;




&lt;/li&gt;
&lt;li&gt;Modify the &lt;code&gt;build.xml&lt;/code&gt; file.&lt;br /&gt;


The &lt;code&gt;build.xml&lt;/code&gt; file is the build file that Apache Ant uses to compile and execute the JDBC samples. The files &lt;code&gt;properties/javadb-build-properties.xml&lt;/code&gt; and &lt;code&gt;properties/mysql-build-properties.xml&lt;/code&gt; contain additional Apache Ant properties required for Java DB and MySQL, respectively. The files &lt;code&gt;properties/javadb-sample-properties.xml&lt;/code&gt; and &lt;code&gt;properties/mysql-sample-properties.xml&lt;/code&gt; contain properties required by the sample.&lt;br /&gt;


Modify these XML files as follows:&lt;br /&gt;


&lt;ol&gt;
&lt;li&gt;In the &lt;code&gt;build.xml&lt;/code&gt; file, modify the property &lt;code&gt;ANTPROPERTIES&lt;/code&gt; to refer to either &lt;code&gt;properties/javadb-build-properties.xml&lt;/code&gt; or &lt;code&gt;properties/mysql-build-properties.xml&lt;/code&gt;, depending on your DBMS. For example, if you are using Java DB, your &lt;code&gt;build.xml&lt;/code&gt; file would contain this:&lt;br /&gt;


  &lt;pre&gt;&amp;lt;property name=&quot;ANTPROPERTIES&quot; value=&quot;properties/javadb-build-properties.xml&quot;/&amp;gt;

  &amp;lt;import file=&quot;${ANTPROPERTIES}&quot;/&amp;gt;&lt;/pre&gt;
Similarly, if you are using MySQL, your &lt;code&gt;build.xml&lt;/code&gt; file would contain this:&lt;br /&gt;


  &lt;pre&gt;&amp;lt;property name=&quot;ANTPROPERTIES&quot; value=&quot;properties/mysql-build-properties.xml&quot;/&amp;gt;

  &amp;lt;import file=&quot;${ANTPROPERTIES}&quot;/&amp;gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;In the &lt;code&gt;properties/javadb-build-properties.xml&lt;/code&gt; or &lt;code&gt;properties/mysql-build-properties.xml&lt;/code&gt; file (depending on your DBMS), modify the following properties, as described in the following table:&lt;br /&gt;


&lt;table border=&quot;1&quot; summary=&quot;DBMS-specific build properties&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;th&gt;Property&lt;/th&gt;
    &lt;th&gt;Description&lt;/th&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;JAVAC&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The full path name of your Java compiler, &lt;code&gt;javac&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;JAVA&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The full path name of your Java runtime executable, &lt;code&gt;java&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;PROPERTIESFILE&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The name of the properties file, either &lt;code&gt;properties/javadb-sample-properties.xml&lt;/code&gt; or &lt;code&gt;properties/mysql-sample-properties.xml&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;MYSQLDRIVER&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The full path name of your MySQL driver. For Connector/J, this is typically &lt;code&gt;&lt;em&gt;&amp;lt;Connector/J installation directory&amp;gt;&lt;/em&gt;/mysql-connector-java-&lt;em&gt;version-number&lt;/em&gt;.jar&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;JAVADBDRIVER&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The full path name of your Java DB driver. This is typically &lt;code&gt;&lt;em&gt;&amp;lt;Java DB installation directory&amp;gt;&lt;/em&gt;/lib/derby.jar&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;DB.VENDOR&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;A value of either &lt;code&gt;derby&lt;/code&gt; or &lt;code&gt;mysql&lt;/code&gt; 
depending on whether you are using Java DB or MySQL, respectively. The 
tutorial uses this value to construct the URL required to connect to the
 DBMS and identify DBMS-specific code and SQL statements.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;DB.DRIVER&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The fully qualified class name of the JDBC driver. For Java DB, this is &lt;code&gt;org.apache.derby.jdbc.EmbeddedDriver&lt;/code&gt;. For MySQL, this is &lt;code&gt;com.mysql.jdbc.Driver&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;DB.HOST&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The host name of the computer hosting your DBMS.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;DB.PORT&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The port number of the computer hosting your DBMS.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;DB.SID&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The name of the database the tutorial creates and uses.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;DB.URL&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The connection URL used to connect to your DBMS. &lt;em&gt;You do not need to change this value.&lt;/em&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;DB.USER&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The name of the user that has access to create databases in the DBMS.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;DB.PASSWORD&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The password of the user specified in &lt;code&gt;DB.USER&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;DB.DELIMITER&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The character used to separate SQL statements. &lt;em&gt;Do not change this value.&lt;/em&gt; It should be the semicolon character (&lt;code&gt;;&lt;/code&gt;).&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Modify the tutorial properties file.&lt;br /&gt;


The tutorial samples use the values in either the &lt;code&gt;properties/javadb-sample-properties.xml&lt;/code&gt; and &lt;code&gt;properties/mysql-sample-properties.xml&lt;/code&gt; file (depending on your DBMS) to connect to the DBMS and initialize databases and tables, as described in the following table:&lt;br /&gt;


&lt;table border=&quot;1&quot; summary=&quot;DBMS-specific sample properties&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;th&gt;Property&lt;/th&gt;
    &lt;th&gt;Description&lt;/th&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;dbms&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;A value of either &lt;code&gt;derby&lt;/code&gt; or &lt;code&gt;mysql&lt;/code&gt; 
depending on whether you are using Java DB or MySQL, respectively. The 
tutorial uses this value to construct the URL required to connect to the
 DBMS and identify DBMS-specific code and SQL statements.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;jar_file&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The full path name of the JAR file that contains all the class files of this tutorial. Only the sample &lt;code&gt;StoredProcedureJavaDBSample.java&lt;/code&gt; requires this value. See &lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/storedprocedures.html&quot;&gt;Using Stored Procedures&lt;/a&gt; for more information.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;driver&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The fully qualified class name of the JDBC driver. For Java DB, this is &lt;code&gt;org.apache.derby.jdbc.EmbeddedDriver&lt;/code&gt;. For MySQL, this is &lt;code&gt;com.mysql.jdbc.Driver&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;database_name&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The name of the database the tutorial creates and uses.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;user_name&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The name of the user that has access to create databases in the DBMS.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;password&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The password of the user specified in &lt;code&gt;user_name&lt;/code&gt;.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;server_name&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The host name of the computer hosting your DBMS.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;port_number&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;The port number of the computer hosting your DBMS.&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/li&gt;
&lt;li&gt;Compile the samples.&lt;br /&gt;


At a command prompt, change the current directory to &lt;code&gt;&lt;em&gt;&amp;lt;JDBC tutorial directory&amp;gt;&lt;/em&gt;&lt;/code&gt;. From this directory, run the following command to compile the samples:&lt;br /&gt;


&lt;code&gt;ant compile&lt;/code&gt;&lt;br /&gt;


&lt;/li&gt;
&lt;li&gt;Run the samples.&lt;br /&gt;


Each target in the &lt;code&gt;build.xml&lt;/code&gt; file corresponds to a Java class or SQL script in the JDBC samples. The following table lists the targets in the &lt;code&gt;build.xml&lt;/code&gt; file, which class or script each target executes, and other classes or files each target requires:&lt;br /&gt;


&lt;table border=&quot;1&quot; summary=&quot;build.xml targets&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;th&gt;Ant Target&lt;/th&gt;
    &lt;th&gt;Class or SQL Script&lt;/th&gt;
    &lt;th&gt;Other Required Classes or Files&lt;/th&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;drop-tables&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;drop-tables.sql&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;No other required files&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;build-tables&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;build-tables.sql&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;Runs the target &lt;code&gt;drop-tables&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;populate-tables&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;populate-tables.sql&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;Runs the target &lt;code&gt;build-tables&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;javadb-create-procedure&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;javadb-create-procedure.sql&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;No other required files&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;mysql-create-procedure&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;See the &lt;code&gt;build.xml&lt;/code&gt; file to view SQL statements that are executed.&lt;/td&gt;
    &lt;td&gt;No other required files&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;run&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;JDBCTutorialUtilities&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;No other required classes&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;runct&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;CoffeesTable&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;JDBCTutorialUtilities&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;runst&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;SuppliersTable&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;JDBCTutorialUtilities&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;runjs&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;JoinSample&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;JDBCTutorialUtilities&lt;/code&gt;, &lt;code&gt;CoffeesTable&lt;/code&gt;, &lt;code&gt;SuppliersTable&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;runspjavadb&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;StoredProcedureJavaDBSample&lt;/code&gt;&lt;br /&gt;

        &lt;strong&gt;Note&lt;/strong&gt;: This class requires extra configuration. See &lt;a href=&quot;http://download.oracle.com/javase/tutorial/jdbc/basics/storedprocedures.html&quot;&gt;Using Stored Procedures&lt;/a&gt; for more information.&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;JDBCTutorialUtilities&lt;/code&gt;, &lt;code&gt;SuppliersTable&lt;/code&gt;, &lt;code&gt;CoffeesTable&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;&lt;code&gt;runspmysql&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;StoredProcedureMySQLSample&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;JDBCTutorialUtilities&lt;/code&gt;, &lt;code&gt;SuppliersTable&lt;/code&gt;, &lt;code&gt;CoffeesTable&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
For example, to run the class &lt;code&gt;CoffeesTable&lt;/code&gt;, change the current directory to &lt;code&gt;&lt;em&gt;&amp;lt;JDBC tutorial directory&amp;gt;&lt;/em&gt;&lt;/code&gt;, and from this directory, run the following command:&lt;br /&gt;


&lt;pre&gt;ant runct&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/3463363850589609099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcgetting-started.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3463363850589609099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/3463363850589609099'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/jdbcgetting-started.html' title='JDBC:Getting Started'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-906339905955713727</id><published>2011-01-15T11:58:00.001-08:00</published><updated>2011-01-15T11:58:26.728-08:00</updated><title type='text'>20 money-saving tips for All students</title><content type='html'>&lt;!--[if !mso]&gt;
&lt;style&gt;
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
&lt;/style&gt;
&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:WordDocument&gt;
  &lt;w:View&gt;Normal&lt;/w:View&gt;
  &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;
  &lt;w:TrackMoves/&gt;
  &lt;w:TrackFormatting/&gt;
  &lt;w:PunctuationKerning/&gt;
  &lt;w:ValidateAgainstSchemas/&gt;
  &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;
  &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;
  &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;
  &lt;w:DoNotPromoteQF/&gt;
  &lt;w:LidThemeOther&gt;EN-US&lt;/w:LidThemeOther&gt;
  &lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt;
  &lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;
  &lt;w:Compatibility&gt;
   &lt;w:BreakWrappedTables/&gt;
   &lt;w:SnapToGridInCell/&gt;
   &lt;w:WrapTextWithPunct/&gt;
   &lt;w:UseAsianBreakRules/&gt;
   &lt;w:DontGrowAutofit/&gt;
   &lt;w:SplitPgBreakAndParaMark/&gt;
   &lt;w:DontVertAlignCellWithSp/&gt;
   &lt;w:DontBreakConstrainedForcedTables/&gt;
   &lt;w:DontVertAlignInTxbx/&gt;
   &lt;w:Word11KerningPairs/&gt;
   &lt;w:CachedColBalance/&gt;
  &lt;/w:Compatibility&gt;
  &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;
  &lt;m:mathPr&gt;
   &lt;m:mathFont m:val=&quot;Cambria Math&quot;/&gt;
   &lt;m:brkBin m:val=&quot;before&quot;/&gt;
   &lt;m:brkBinSub m:val=&quot;--&gt;
   &lt;m:smallfrac m:val=&quot;off&quot;&gt;
   &lt;m:dispdef&gt;
   &lt;m:lmargin m:val=&quot;0&quot;&gt;
   &lt;m:rmargin m:val=&quot;0&quot;&gt;
   &lt;m:defjc m:val=&quot;centerGroup&quot;&gt;
   &lt;m:wrapindent m:val=&quot;1440&quot;&gt;
   &lt;m:intlim m:val=&quot;subSup&quot;&gt;
   &lt;m:narylim m:val=&quot;undOvr&quot;&gt;
  &lt;/m:narylim&gt;&lt;/m:intlim&gt;
&lt;/m:wrapindent&gt;&lt;!--[endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;w:LatentStyles DefLockedState=&quot;false&quot; DefUnhideWhenUsed=&quot;true&quot;
  DefSemiHidden=&quot;true&quot; DefQFormat=&quot;false&quot; DefPriority=&quot;99&quot;
  LatentStyleCount=&quot;267&quot;&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;0&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Normal&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;heading 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 7&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 8&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 9&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 7&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 8&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 9&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;35&quot; QFormat=&quot;true&quot; Name=&quot;caption&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;10&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Title&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;1&quot; Name=&quot;Default Paragraph Font&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;11&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtitle&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;22&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Strong&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;20&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Emphasis&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;59&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Table Grid&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; UnhideWhenUsed=&quot;false&quot; Name=&quot;Placeholder Text&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;1&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;No Spacing&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; UnhideWhenUsed=&quot;false&quot; Name=&quot;Revision&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;34&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;List Paragraph&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;29&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Quote&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;30&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Quote&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 1&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 2&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 3&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 4&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 5&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 6&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;19&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtle Emphasis&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;21&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Emphasis&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;31&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtle Reference&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;32&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Reference&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;33&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Book Title&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;37&quot; Name=&quot;Bibliography&quot;/&gt;
  &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; QFormat=&quot;true&quot; Name=&quot;TOC Heading&quot;/&gt;
 &lt;/w:LatentStyles&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt;
&lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:&quot;Table Normal&quot;;
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-priority:99;
 mso-style-qformat:yes;
 mso-style-parent:&quot;&quot;;
 mso-padding-alt:0in 5.4pt 0in 5.4pt;
 mso-para-margin-top:0in;
 mso-para-margin-right:0in;
 mso-para-margin-bottom:10.0pt;
 mso-para-margin-left:0in;
 line-height:115%;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;}
&lt;/style&gt;
&lt;![endif]--&gt;

&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;width: 100%;&quot;&gt;
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;td style=&quot;padding: 0in;&quot; valign=&quot;top&quot;&gt;
  &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 18pt;&quot;&gt;These
  will not only help you save and manage your money better, but also tell you
  how to make some on your own. Go on, read them-and have 20 times more fun.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style=&quot;padding: 0in;&quot; valign=&quot;top&quot;&gt;&lt;br /&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style=&quot;padding: 0in;&quot; valign=&quot;top&quot;&gt;
  &lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoNormalTable&quot; style=&quot;width: 100%;&quot;&gt;
   &lt;tbody&gt;
&lt;tr&gt;
    &lt;td colspan=&quot;2&quot; style=&quot;padding: 0in; width: 100%;&quot; valign=&quot;top&quot; width=&quot;100%&quot;&gt;
    &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;If
    you are a college student, cashlessness is a perpetual state of existence.
    Short on funds and craving for pleasurable pursuits, you have two options.
    Resign to your impoverished status, or go through the 20 pointers we have
    compiled for you. These will not only help you save and manage your money
    better, but also tell you how to make some on your own. Go on, read
    them-and have 20 times more fun.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Managing
    Your Money&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Make
         A Monthly Budget: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;This
         doesn&#39;t have to be a complicated number-crunching exercise. A simple
         Excel sheet or the planner in your mobile will suffice. The idea is to
         keep track of your monthly expenses and plug any unnecessary spending.
         Start by listing your fixed expenditure like transportation cost,
         food, etc, and keep aside money for these. The balance can then be
         used for discretionary expenses like shopping, gifting or partying.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Plan
         Your Purchases:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;
         Has the Rs. 1,000 spent on a dress for freshers&#39; night left you broke?
         Simple mathematics and a bit of planning could have helped you avoid
         the situation. Cutting down your expenses by Rs. 250 every month would
         have saved you Rs. 1,000 in just four months and made the dress
         affordable. Planning ahead is an easy way to prevent bankruptcy.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Fund
         For Emergencies Or Opportunities: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&quot;Since students don&#39;t have a steady source of
         income, it is a must to have a fund for situations that might require
         some quick cash,&quot; says financial adviser Rohit Sarin. Rather than
         borrowing from friends, making small adjustments, such as skipping a
         movie at the multiplex or ordering pizzas less often, can help you
         prepare for both opportunities and crises.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Select
         A Good Savings Account:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;
         Rather than going for a regular bank deposit, look at products
         specifically designed for students. Apart from the zero-balance
         facility and regular freebies, students&#39; savings accounts have other
         benefits which make them better than a no-frills account. For
         instance, free demand drafts for paying examination fee or buying
         application forms are offered to student account holders of Punjab
         National Bank, Corporation Bank and State Bank of India. Punjab
         National Bank also provides an overdraft facility, Maharashtra Bank
         offers free assistance in sending applications to universities abroad
         and you can get concessional educational loans if your account is with
         Vijaya Bank.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Avoid
         Debt: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;If you have to swipe, use a
         debit card. &quot;Unlike credit cards, there is no interest or
         late-payment charge in the case of a debit card, so there is no danger
         of stacking up a debt. It will also help instill financial discipline
         if you spend only what you have,&quot; says Sarin.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Prepay
         Mobile Expenses: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Choose
         a prepaid plan to avoid ugly surprises at the end of each month. You
         can also customise to make the plan cheaper. So if your calls don&#39;t
         last more than a few seconds, get a pay-per-second plan, or if you are
         an SMS addict, add a message card to make them free.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Use
         Free ATMs:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt; After the first five
         transactions in a month, you are charged Rs. 20 per cash withdrawal if
         you are operating an ATM outside your bank&#39;s network. So, regular
         withdrawals from ATMs outside the surcharge-free network can be
         expensive. Avoid them.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Insurance?
         Not Required:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;
         Since students don&#39;t have any earning to protect or dependants to take
         care of, they don&#39;t need any cover, says Sarin. Also, in case of a
         medical emergency, you have your dependent card to fall back upon. An
         insurance policy is useless, unless you have a loan to return.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Maximising
    Your Money&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Patience
         Pays:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt; Even if you are dying to
         buy the new Android phone, waiting for a few months will be a good
         idea. Gadgets&#39; prices tend to fall as soon as there is a successor in
         the market. So, postponing your purchase for the same model by a month
         or two can get you a price cut.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Swap
         &#39;n&#39; Save:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt; Haven&#39;t you always
         exchanged your books and CDs with friends and cousins? Now you can do
         the same online to get a wider choice and save as well. Websites such
         as bookchums.com, swapadda.com and booksvilla.com can help you search
         for a person to exchange your belongings with.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Search
         For Online Bargains:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;
         Before you go for a movie or lunch with friends the next time, do not
         forget to surf the Internet. Discount sites are mushrooming by the
         day, with some offering as much as 95% off on a variety of products
         and services. You can get huge bargains at restaurants, on multiplex
         movie tickets, apparel, gyms, spas and a lot more.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Go
         Shopping With A List: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Did
         you go to buy a lip balm and returned with a bagful of cosmetics? An
         excellent way to control impulsive buying is to make a list before
         heading towards the market. Though the shelves are filled with
         temptations, pledge to stick to your requirements, and you will have
         more money at the end of the month.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Contribute
         To Save:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt; Buying books often burns a
         hole in your pocket. Instead, ask your friends to chip in and buy them
         together. The unit cost will reduce and you can take turns to make
         notes. Once you get the degree, they can be sold and the money can be
         divided equally among the group members. This can be done for other
         things, such DVDs and computer games, as well.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Party
         At Home: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Rather than spending
         thousands of rupees in a restaurant, take permission from your parents
         to organise a barbeque party in your backyard. If this sounds like a
         lot of work, just spruce up your room and order some good food to have
         fun at half rate.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Head
         Outdoors:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt; Rather than confining
         yourself to expensive man-made options, occasionally opt for outdoor
         experiences. There&#39;s a lot to choose from. You can go picnicking,
         camping or bicycling with friends. Spending time with nature is both
         fun and frugal.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Inexpensive
         Entertainment:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;
         The city&#39;s community centres offer several quality entertainment
         options which are also extremely inexpensive. You can opt for musical
         performances, film festivals, art exhibits, theatre productions, dance
         recitals, sporting events and much more. Check out the local
         newspapers to keep track of such events.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Free
         Facilities:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt; In all likelihood, there
         are several free services, such as the Internet, gym, dance classes,
         photography clubs and free training for various courses, that your
         educational institute offers. Utilise these in-house facilities to
         save money.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Making
    Money&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ol start=&quot;1&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Tap
         Your Hobbies:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;
         As a college student, baking was a hobby for Sonal Khurana, till her
         friends suggested that she turn it into a side business. The
         22-year-old began by putting up stalls in college fests and taking
         orders from classmates. Last year, she managed a profit of Rs. 1.62
         lakh and has recently turned it into a full-time profession. Hers is
         not the only money-making skill that you can tap. Arpita Kala, a
         21-year-old print media student, customises shoes and charges Rs. 450
         per order. You could even form your own music band, or go for the more
         common pursuits like blogging and photography. The bottom line? If you
         have talent, turn it into a trade.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Part-Time
         Positions:&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt; Get a part-time job to
         supplement your pocket money. There are various profiles, such as
         content writers, BPO executives, transcriptionists, to choose from.
         You could also opt for unusual roles like a city tour guide or
         recruitment agent. Then there are the home-based online jobs, but you
         need to be careful before applying as many are scams. Job search sites
         like searchmycapus.com and firstnaukri.com, which are specifically
         designed for college students, can be helpful. You can also seek
         advice from your college placement cell.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Opportunities
         In College: &lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Being a part af cultural
         societies and participating in competitions that offer cash prizes can
         fetch you a few bucks. In addition, find out about the scholarships
         offered by your institution and the criteria to avail of them. And if
         any of your professors is involved in research work, enquire if they
         need assistance with their surveys or other errands.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;i&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Source:
    Money Today&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
   &lt;/tr&gt;
&lt;tr&gt;
    &lt;td colspan=&quot;2&quot; style=&quot;padding: 0in;&quot;&gt;
    &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;
   &lt;/tr&gt;
&lt;tr&gt;
    &lt;td colspan=&quot;2&quot; style=&quot;padding: 0in;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
   &lt;/tr&gt;
&lt;tr&gt;
    &lt;td colspan=&quot;2&quot; style=&quot;padding: 0in;&quot;&gt;
    &lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/td&gt;
   &lt;/tr&gt;
&lt;tr&gt;
    &lt;td style=&quot;padding: 0in;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
    &lt;td style=&quot;padding: 0in;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
   &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/m:defjc&gt;&lt;/m:rmargin&gt;&lt;/m:lmargin&gt;&lt;/m:dispdef&gt;&lt;/m:smallfrac&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/906339905955713727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/20-money-saving-tips-for-all-students.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/906339905955713727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/906339905955713727'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/20-money-saving-tips-for-all-students.html' title='20 money-saving tips for All students'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5316342384202108452.post-8801273754910944801</id><published>2011-01-14T02:20:00.000-08:00</published><updated>2011-01-14T02:20:01.354-08:00</updated><title type='text'>Java Neurons: Remember Me</title><content type='html'>&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:WordDocument&gt;   &lt;w:View&gt;Normal&lt;/w:View&gt;   &lt;w:Zoom&gt;0&lt;/w:Zoom&gt;   &lt;w:TrackMoves/&gt;   &lt;w:TrackFormatting/&gt;   &lt;w:PunctuationKerning/&gt;   &lt;w:ValidateAgainstSchemas/&gt;   &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt;   &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt;   &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt;   &lt;w:DoNotPromoteQF/&gt;   &lt;w:LidThemeOther&gt;EN-US&lt;/w:LidThemeOther&gt;   &lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt;   &lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt;   &lt;w:Compatibility&gt;    &lt;w:BreakWrappedTables/&gt;    &lt;w:SnapToGridInCell/&gt;    &lt;w:WrapTextWithPunct/&gt;    &lt;w:UseAsianBreakRules/&gt;    &lt;w:DontGrowAutofit/&gt;    &lt;w:SplitPgBreakAndParaMark/&gt;    &lt;w:DontVertAlignCellWithSp/&gt;    &lt;w:DontBreakConstrainedForcedTables/&gt;    &lt;w:DontVertAlignInTxbx/&gt;    &lt;w:Word11KerningPairs/&gt;    &lt;w:CachedColBalance/&gt;   &lt;/w:Compatibility&gt;   &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt;   &lt;m:mathPr&gt;    &lt;m:mathFont m:val=&quot;Cambria Math&quot;/&gt;    &lt;m:brkBin m:val=&quot;before&quot;/&gt;    &lt;m:brkBinSub m:val=&quot;--&gt;    &lt;m:smallfrac m:val=&quot;off&quot;&gt;    &lt;m:dispdef&gt;    &lt;m:lmargin m:val=&quot;0&quot;&gt;    &lt;m:rmargin m:val=&quot;0&quot;&gt;    &lt;m:defjc m:val=&quot;centerGroup&quot;&gt;    &lt;m:wrapindent m:val=&quot;1440&quot;&gt;    &lt;m:intlim m:val=&quot;subSup&quot;&gt;    &lt;m:narylim m:val=&quot;undOvr&quot;&gt;   &lt;/m:narylim&gt;&lt;/m:intlim&gt; &lt;/m:wrapindent&gt;&lt;!--[endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;  &lt;w:LatentStyles DefLockedState=&quot;false&quot; DefUnhideWhenUsed=&quot;true&quot;
  DefSemiHidden=&quot;true&quot; DefQFormat=&quot;false&quot; DefPriority=&quot;99&quot;
  LatentStyleCount=&quot;267&quot;&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;0&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Normal&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;heading 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 7&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 8&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;9&quot; QFormat=&quot;true&quot; Name=&quot;heading 9&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 7&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 8&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; Name=&quot;toc 9&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;35&quot; QFormat=&quot;true&quot; Name=&quot;caption&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;10&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Title&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;1&quot; Name=&quot;Default Paragraph Font&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;11&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtitle&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;22&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Strong&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;20&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Emphasis&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;59&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Table Grid&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; UnhideWhenUsed=&quot;false&quot; Name=&quot;Placeholder Text&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;1&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;No Spacing&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; UnhideWhenUsed=&quot;false&quot; Name=&quot;Revision&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;34&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;List Paragraph&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;29&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Quote&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;30&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Quote&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 1&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 2&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 3&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 4&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 5&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;60&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Shading Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;61&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light List Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;62&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Light Grid Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;63&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 1 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;64&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Shading 2 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;65&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 1 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;66&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium List 2 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;67&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 1 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;68&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 2 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;69&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Medium Grid 3 Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;70&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Dark List Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;71&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Shading Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;72&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful List Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;73&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; Name=&quot;Colorful Grid Accent 6&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;19&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtle Emphasis&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;21&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Emphasis&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;31&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Subtle Reference&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;32&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Intense Reference&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;33&quot; SemiHidden=&quot;false&quot;
   UnhideWhenUsed=&quot;false&quot; QFormat=&quot;true&quot; Name=&quot;Book Title&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;37&quot; Name=&quot;Bibliography&quot;/&gt;   &lt;w:LsdException Locked=&quot;false&quot; Priority=&quot;39&quot; QFormat=&quot;true&quot; Name=&quot;TOC Heading&quot;/&gt;  &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 10]&gt; &lt;style&gt;
 /* Style Definitions */
 table.MsoNormalTable
 {mso-style-name:&quot;Table Normal&quot;;
 mso-tstyle-rowband-size:0;
 mso-tstyle-colband-size:0;
 mso-style-noshow:yes;
 mso-style-priority:99;
 mso-style-qformat:yes;
 mso-style-parent:&quot;&quot;;
 mso-padding-alt:0in 5.4pt 0in 5.4pt;
 mso-para-margin-top:0in;
 mso-para-margin-right:0in;
 mso-para-margin-bottom:10.0pt;
 mso-para-margin-left:0in;
 line-height:115%;
 mso-pagination:widow-orphan;
 font-size:11.0pt;
 font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;
 mso-ascii-font-family:Calibri;
 mso-ascii-theme-font:minor-latin;
 mso-hansi-font-family:Calibri;
 mso-hansi-theme-font:minor-latin;
 mso-bidi-font-family:&quot;Times New Roman&quot;;
 mso-bidi-theme-font:minor-bidi;}
&lt;/style&gt; &lt;![endif]--&gt;  &lt;/m:defjc&gt;&lt;/m:rmargin&gt;&lt;/m:lmargin&gt;&lt;/m:dispdef&gt;&lt;/m:smallfrac&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;u&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;Java Neurons: Remember Me- Time to pump some neurons&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;1.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Statement end in semicolon;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;2.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Code blocks are defined by a pair of curly braces {}&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;3.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Declare an int variable with a name and a type and a type: &lt;b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;int x;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;4.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;The &lt;b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;assignment operator &lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;is one euals sign &lt;b&gt;=&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;5.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;A while loop run everything within its block (defined by curly braces) as long as the conditional test is &lt;b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;true &lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;6.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;If the conditional test is &lt;b&gt;false, &lt;/b&gt;the while loop code block won’t run, and execution will move down to the code immediately after the loop block.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;7.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Put a Boolean test inside parentheses:&lt;span&gt;&amp;nbsp; &lt;/span&gt;while&lt;span&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;(x&lt;span&gt;&amp;nbsp; &lt;/span&gt;==&lt;span&gt;&amp;nbsp; &lt;/span&gt;4) &lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;{&lt;span&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;8.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;When you design a class, think about the objects that will be created from that class type. Think about:&lt;span&gt;&amp;nbsp; &lt;/span&gt;&lt;b&gt;things the object knows,&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;things the object does&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;9.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Things an object knows about itself are called &lt;b&gt;instance variable.&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;10.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Things an object can do are called &lt;b&gt;method.&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;11.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;A &lt;/b&gt;class in not an object. ( but it’s used to construct them). A class is a blueprint fpr an object. It &lt;span&gt;&amp;nbsp;&lt;/span&gt;tell the &lt;b&gt;JVM &lt;/b&gt;how to make an object of that particular type. Each object made from that class can have its own value for the instance variable of that class.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;12.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;As &lt;/b&gt;long as you’r in main(), you’r not really in Objectville. It’s fine for test program to run within the main method, but in a true &lt;b&gt;OO &lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;application, you need object talking to other objects, as opposed to a static main() method creating and testing object.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;13.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;The two uses of main: &lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;to test your real class.&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;To launch/start your java application&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;14.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Object-oriented programming lets you extend a program without having to tuch previously-tested, working code.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;15.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;All java code is define in a&lt;b&gt; class&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;16.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;A class describes how to make an object of that class type. &lt;b&gt;A class is like blueprint.&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;17.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;An object can take care of itself; you don’t have to know to care how the object does it.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;18.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;An object knows about itself are called &lt;b&gt;instance variable. &lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;They represent the state of an object.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;19.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Thing an object does are called &lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;method. &lt;/b&gt;They represent the behavior of an object.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;20.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;When you create a class, you may also want to create a separate test class which you’ll use to create object of your new class type.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;21.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;A class can &lt;b&gt;inherit &lt;/b&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;instance variables and methods from a more abstract &lt;b&gt;superclass.&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;22.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;At runtime, a java program is nothing more than object ‘talking’ to other objects.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;23.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Variable come in two flavors: permitive and reference. It must always be declared with a name and a type.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;24.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;A primitive variable value is the bits representing the value (5, ‘a’, true, 3.1416, etc).&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;25.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;A reference variable value is the bits representing a way to get to an object on the heap.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;26.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;A reference variable is like a remote control. Using the dot operator(.) on a reference variable is like pressing a button on the remote control to access a method or instance variable.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;27.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;A reference variable has a value of null when it is not referencing any object.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;font-size: 16pt; line-height: 115%;&quot;&gt;&lt;span&gt;28.&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;An array is always an object, even if the array is declared to hold primitives, there is no such thing as a primitive array, only an array that hold primitives.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://javaachiver.blogspot.com/feeds/8801273754910944801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://javaachiver.blogspot.com/2011/01/java-neurons-remember-me.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/8801273754910944801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5316342384202108452/posts/default/8801273754910944801'/><link rel='alternate' type='text/html' href='http://javaachiver.blogspot.com/2011/01/java-neurons-remember-me.html' title='Java Neurons: Remember Me'/><author><name>alok</name><uri>http://www.blogger.com/profile/13104672777909440505</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>