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

<channel>
	<title>Java HowTo Guide</title>
	<atom:link href="http://www.javahowtoguide.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javahowtoguide.com</link>
	<description>Learn JAVA with US</description>
	<lastBuildDate>Tue, 20 Dec 2011 10:10:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>JAVA &#8211; Abstract Classes and Methods</title>
		<link>http://www.javahowtoguide.com/java-abstract-classes-and-methods/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=java-abstract-classes-and-methods</link>
		<comments>http://www.javahowtoguide.com/java-abstract-classes-and-methods/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 10:10:47 +0000</pubDate>
		<dc:creator>Java Tutor</dc:creator>
				<category><![CDATA[Advanced JAVA]]></category>
		<category><![CDATA[Classes]]></category>
		<category><![CDATA[Abstract Class]]></category>
		<category><![CDATA[Abstract Method]]></category>
		<category><![CDATA[JAVA Classes]]></category>

		<guid isPermaLink="false">http://www.javahowtoguide.com/?p=29</guid>
		<description><![CDATA[<p style="text-align: left;" align="center">The definition of a class should not be instantiated since it only represents the abstract concept. For example, the instance of pet can not be seen. What you can see are the instances of cat, dog, pig or horse. The instance of pet can not be seen and does not make sense.</p> <p>Abstract Classes</p> <p>As with object-oriented programming, declaring abstract concepts might be desired, but there is no possibility that you can create an instance of same. For example, the abstract concept of numbers is represented by Number class available with the java.lang package. The Number class serves as a model for numbers used in programs but is impossible to create the generic object.</p> <p>The Number class is parent class of number of other number classes like Integer and double which implements specific types of numbers. The abstracted class represented by the number class, which implements abstract concepts. Abstract classes can be subclassed but it cannot have instance of it.</p> <p></p> <p>If you are declaring an abstract class, Use keyword ‘abstract’ just before ‘class’ keyword. This tells compiler that you are declaring an abstract class. In syntax form:</p> <p>abstract class class_name {</p> <p>. . .</p> <p>}</p> <p>If you try to create instance of an abstract class, a compiler will would refuse to compile the program and returns an error message. For example, a declaration written as the following can produce an error due to the instantiated abstract class:</p> <p>AbstractTest.java:6: class class_name is an abstract class……..</p> <p>1 error</p> <p>Abstract Methods</p> <p>Methods that do not have implementation which are contained in abstract class are called Abstract methods. The abstract class can define an interface which can be used for programming using subclasses. The method declarations for all the necessary methods to implement the programming interface are stated on the <p>Continue reading <a href="http://www.javahowtoguide.com/java-abstract-classes-and-methods/">JAVA &#8211; Abstract Classes and Methods</a></p>]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;" align="center">The definition of a class should not be instantiated since it only represents the abstract concept. For example, the instance of pet can not be seen. What you can see are the instances of cat, dog, pig or horse. The instance of pet can not be seen and does not make sense.</p>
<p><strong>Abstract Classes</strong></p>
<p>As with object-oriented programming, declaring abstract concepts might be desired, but there is no possibility that you can create an instance of same. For example, the abstract concept of numbers is represented by Number class available with the java.lang package. The Number class serves as a model for numbers used in programs but is impossible to create the generic object.</p>
<p>The Number class is parent class of number of other number classes like Integer and double which implements specific types of numbers. The abstracted class represented by the number class, which implements abstract concepts. Abstract classes can be subclassed but it cannot have instance of it.</p>
<p><span id="more-29"></span></p>
<p>If you are declaring an abstract class, Use keyword ‘abstract’ just before ‘class’ keyword. This tells compiler that you are declaring an abstract class. In syntax form:</p>
<p>abstract class class_name {</p>
<p>. . .</p>
<p>}</p>
<p>If you try to create instance of an abstract class, a compiler will would refuse to compile the program and returns an error message. For example, a declaration written as the following can produce an error due to the instantiated abstract class:</p>
<p>AbstractTest.java:6: class class_name is an abstract class……..</p>
<p>1 error</p>
<p><strong>Abstract Methods</strong></p>
<p>Methods that do not have implementation which are contained in abstract class are called Abstract methods. The abstract class can define an interface which can be used for programming using subclasses. The method declarations for all the necessary methods to implement the programming interface are stated on the subclasses.</p>
<p>In an object-oriented program, you may create circles, rectangles, Bezier and lines. These graphing objects have some similarities such as state and behavior. The state of the object can be defined through its position and bounding box. The behavior may be stated to move, resize or draw the object. These shared properties can be declared to inherit from a single parent object which can be defined as the class GraphicObject.</p>
<p>On the other hand, the objects are different depending upon what shape should be drawn.  The process of drawing rectangle is different from the one used to draw a circle. The following example clearly shows the properties of an abstract superclass.</p>
<p>The GraphicObject should be declared to create member variables and methods and to be shared with children classes. The superclass will have move_To(), current_position methods and are shared by all subclasses. There are other abstract methods that are declared by the abstract class GraphicObject but implemented in different ways. Such abstract methods is the draw() method, which has no default implementation but should be implemented in all subclasses. Putting it in syntax form, the class GraphicObject would appear as the following:</p>
<p>abstract class Example_of_Graphic_Object {</p>
<p>int x_var, y_var;</p>
<p>. . .</p>
<p>void move_To(int newX_var, int newY_var) {</p>
<p>. . .</p>
<p>}</p>
<p>abstract void draw_shape();</p>
<p>}</p>
<p>A non-abstract subclass of the class GraphicObject such as Rectangle_class and Circle_class should provide the implementation for the draw() method.</p>
<p>class Circle_class extends Example_of_Graphic_Object {</p>
<p>void draw_shape() {</p>
<p>. . .</p>
<p>}</p>
<p>}</p>
<p>class Rectangle_class extends Example_of_Graphic_Object {</p>
<p>void draw_shape() {</p>
<p>. . .</p>
<p>}</p>
<p>}</p>
<p>The abstract class may or may not contain an abstract method. However, any class containing an abstract method or does not have an implementation for the declared abstract methods in the superclasses should be treated as abstract class.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javahowtoguide.com/java-abstract-classes-and-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAVA &#8211; Static Member classes</title>
		<link>http://www.javahowtoguide.com/java-static-member-classes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=java-static-member-classes</link>
		<comments>http://www.javahowtoguide.com/java-static-member-classes/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 10:10:12 +0000</pubDate>
		<dc:creator>Java Tutor</dc:creator>
				<category><![CDATA[Advanced JAVA]]></category>
		<category><![CDATA[Classes]]></category>
		<category><![CDATA[JAVA Classes]]></category>
		<category><![CDATA[Static Member classes]]></category>

		<guid isPermaLink="false">http://www.javahowtoguide.com/?p=39</guid>
		<description><![CDATA[<p style="text-align: left;" align="center">The static member class is similar to any other class, but this type of class is nested within another simple class. The static member can be used both by the external classes and the class in which it is defined. The static member class can be used by hierarchical name using name of containing class as prefix.</p> <p>Some of the features of the static member class are:</p> The static member class is always defined with static modifier. This way static member class becomes equivalent to all other class members which are declared with static modifier. A static member class can use access control modifiers, without any alteration in the meaning of these modifiers. The static member class can access all the static members of containing class (private member as well). ses. The static member class can not be associated instances of the containing class. <p>However, the declaration of the static member class imposes certain restrictions too. These are:</p> The static member class and its containing class should have different names. These classes can be defined only within the static member classes or Top-level classes. <p>Also, in case the static member classes need to be used by classes outside the containing classes, this class is used by combining its name and name inner class.</p> ]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;" align="center">The static member class is similar to any other class, but this type of class is nested within another simple class. The static member can be used both by the external classes and the class in which it is defined. The static member class can be used by hierarchical name using name of containing class as prefix.</p>
<p>Some of the features of the static member class are:</p>
<ul>
<li>The static member class is always defined with static modifier. This way static member class becomes equivalent to all other class members which are declared with static modifier.</li>
<li>A static member class can use access control modifiers, without any alteration in the meaning of these modifiers.</li>
<li>The static member class can access all the static members of containing class (private member as well). ses.</li>
<li>The static member class can not be associated instances of the containing class.</li>
</ul>
<div><span id="more-39"></span></div>
<p>However, the declaration of the static member class imposes certain restrictions too. These are:</p>
<ul>
<li>The static member class and its containing class should have different names.</li>
<li>These classes can be defined only within the static member classes or Top-level classes.</li>
</ul>
<p>Also, in case the static member classes need to be used by classes outside the containing classes, this class is used by combining its name and name inner class.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javahowtoguide.com/java-static-member-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAVA &#8211; Initializer blocks</title>
		<link>http://www.javahowtoguide.com/java-initializer-blocks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=java-initializer-blocks</link>
		<comments>http://www.javahowtoguide.com/java-initializer-blocks/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 14:10:25 +0000</pubDate>
		<dc:creator>Java Tutor</dc:creator>
				<category><![CDATA[Advanced JAVA]]></category>
		<category><![CDATA[Building Blocks]]></category>
		<category><![CDATA[Classes]]></category>
		<category><![CDATA[Initializer blocks]]></category>

		<guid isPermaLink="false">http://www.javahowtoguide.com/?p=40</guid>
		<description><![CDATA[<p style="text-align: left;" align="center">As you have already learnt, the initialization expressions of the fields and the code of the constructor methods are used to initialize the objects. A class contains a class initialization method. Though they are both the same, there is only one difference. The class initialization method needs to be explicitly defined in the body of this method. You can write arbitrary codes for initializing the class fields in the Java programming language. This is done using a construct known as a static initializer.</p> <p>A static initializer is nothing but the keyword static followed by a block of code enclosed in curly braces. This keyword can appear in a class definition wherever a field or method definition appears. A class can use multiple initializers where the body of each initializer is contained into the class initialization method. The initializer’s body also contains the static field initialization expressions. A static initializer is similar to a class method. However, it cannot make use of the this keyword, any instance fields or instance methods of the class.</p> <p>The Java 1.1 supports instance initializers in the classes. An instance initializer is similar to static initializers. However, it is used to initialize an object instead of an entire class and does not support the keyword static. A class can support multiple initializers, which can be contained anywhere in the definition of the field or method.</p> <p>Instance initializers are used to initialize arrays or other fields requiring complex initialization. They can also be used to locate the initialization code placed next to the field, instead of separating it off in a constructor method.  However, these initializes are rarely used in the actual programs.</p> ]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;" align="center">As you have already learnt, the initialization expressions of the fields and the code of the constructor methods are used to initialize the objects. A class contains a class initialization method. Though they are both the same, there is only one difference. The class initialization method needs to be explicitly defined in the body of this method. You can write arbitrary codes for initializing the class fields in the Java programming language. This is done using a construct known as a <em>static initializer</em>.</p>
<p>A static initializer is nothing but the keyword static followed by a block of code enclosed in curly braces. This keyword can appear in a class definition wherever a field or method definition appears. A class can use multiple initializers where the body of each initializer is contained into the class initialization method. The initializer’s body also contains the static field initialization expressions. A static initializer is similar to a class method. However, it cannot make use of the this keyword, any instance fields or instance methods of the class.<span id="more-40"></span></p>
<p>The Java 1.1 supports instance initializers in the classes. An instance initializer is similar to static initializers. However, it is used to initialize an object instead of an entire class and does not support the keyword static. A class can support multiple initializers, which can be contained anywhere in the definition of the field or method.</p>
<p>Instance initializers are used to initialize arrays or other fields requiring complex initialization. They can also be used to locate the initialization code placed next to the field, instead of separating it off in a constructor method.  However, these initializes are rarely used in the actual programs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javahowtoguide.com/java-initializer-blocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAVA &#8211; Field Defaults and Initializers</title>
		<link>http://www.javahowtoguide.com/java-field-defaults-and-initializers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=java-field-defaults-and-initializers</link>
		<comments>http://www.javahowtoguide.com/java-field-defaults-and-initializers/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 14:10:23 +0000</pubDate>
		<dc:creator>Java Tutor</dc:creator>
				<category><![CDATA[Advanced JAVA]]></category>
		<category><![CDATA[Building Blocks]]></category>
		<category><![CDATA[Classes]]></category>
		<category><![CDATA[Field Defaults and Initializers]]></category>

		<guid isPermaLink="false">http://www.javahowtoguide.com/?p=41</guid>
		<description><![CDATA[<p style="text-align: left;" align="center">As you have seen earlier, all the fields do not need to be initialized. The member fields of a class are initialized automatically, unlike local variables that need to be explicitly initialized. For example, the primitive data type fields are initialized to a default value of false or zero automatically. Similarly, all fields of reference data types are initialized to null. Java compiler automatically performs this job depending on the default value of a field, and this condition implies to both instance fields and class fields.</p> <p>Now let’s look at a variable declaration. The variable is declared within a Java statement and is initialized when the Java statement is executed. Unlike variables in a method, the field declarations are not a part of any particular method. These cannot be therefore executed as individual statements.</p> <p>On the other hand, the Java compiler automatically generates initialization code that is instance-free. This instance-free initialization code is stored in the class constructor or constructors. The order of the constructor in the source code determines the manner in which it appears in the constructor. Accordingly, the field initializer can use all the initial values of the fields declared before it. If a constructor starting with the this() keyword makes a call to another constructor, the field initialization code is not displayed in the first constructor. Conversely, the method initialization is done by the constructor invoked by the this() call.</p> ]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;" align="center">As you have seen earlier, all the fields do not need to be initialized. The member fields of a class are initialized automatically, unlike local variables that need to be explicitly initialized. For example, the primitive data type fields are initialized to a default value of false or zero automatically. Similarly, all fields of reference data types are initialized to null. Java compiler automatically performs this job depending on the default value of a field, and this condition implies to both instance fields and class fields.</p>
<p>Now let’s look at a variable declaration. The variable is declared within a Java statement and is initialized when the Java statement is executed. Unlike variables in a method, the field declarations are not a part of any particular method. These cannot be therefore executed as individual statements.</p>
<p>On the other hand, the Java compiler automatically generates initialization code that is instance-free. This instance-free initialization code is stored in the class constructor or constructors. The order of the constructor in the source code determines the manner in which it appears in the constructor. Accordingly, the field initializer can use all the initial values of the fields declared before it. If a constructor starting with the this() keyword makes a call to another constructor, the field initialization code is not displayed in the first constructor. Conversely, the method initialization is done by the constructor invoked by the this() call.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javahowtoguide.com/java-field-defaults-and-initializers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAVA &#8211; Defining Multiple Constructors</title>
		<link>http://www.javahowtoguide.com/java-defining-multiple-constructors/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=java-defining-multiple-constructors</link>
		<comments>http://www.javahowtoguide.com/java-defining-multiple-constructors/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 14:10:21 +0000</pubDate>
		<dc:creator>Java Tutor</dc:creator>
				<category><![CDATA[Advanced JAVA]]></category>
		<category><![CDATA[Building Blocks]]></category>
		<category><![CDATA[Classes]]></category>
		<category><![CDATA[Defining Multiple Constructors]]></category>

		<guid isPermaLink="false">http://www.javahowtoguide.com/?p=42</guid>
		<description><![CDATA[<p style="text-align: left;" align="center">Certain objects can be initialized in many different ways and can also be used in multiple ways. For example, in the Circle class that we all are familiar with, the radius of the circle can be initialized to a specified value or a reasonable default value. Therefore, we can use multiple constructors if there are many instances of fields in a program. Let’s see how we can define two constructors for the Circle class:</p> <p>public Circle_class() { radius_var1 = 0.54; }</p> <p>public Circle_class(double radius_var1) {  this.radius_var1 = radius_var1;}</p> <p>We can define as many constructors as we want for a particular class. However, each constructor should have its own parameter list. The Java compiler selects a constructor on its own based on the type of parameters and the number and type of arguments supplied by you.</p> <p align="center">Calling One Constructor from Another</p> <p>The ‘this’ keyword as defined above is used specifically in the case a class has multiple constructors. The ‘this’ keyword is then used to invoke one of the other constructors of the same class. In other words, we can rewrite the two previous Circle constructors as follows:</p> <p>// This is an example of basic constructor: It is used to initialize the radius</p> <p>public Circle_class(double radius_var1) { this.radius_var1 = radius_var1; }</p> <p>// This constructor uses this () to invoke the constructor above</p> <p>public Circle_class() { this(1.0); }</p> <p>The this()keyword is used to invoke methods by calling another constructors of the class. Using the ‘this’ keyword avoids repetition of the code in case of using multiple constructors. This is particularly useful in cases where a large number of constructors share a large amount of initialization code.</p> ]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;" align="center">Certain objects can be initialized in many different ways and can also be used in multiple ways. For example, in the Circle class that we all are familiar with, the radius of the circle can be initialized to a specified value or a reasonable default value. Therefore, we can use multiple constructors if there are many instances of fields in a program. Let’s see how we can define two constructors for the Circle class:</p>
<p>public Circle_class() { radius_var1 = 0.54; }</p>
<p>public Circle_class(double radius_var1) {  this.radius_var1 = radius_var1;}</p>
<p>We can define as many constructors as we want for a particular class. However, each constructor should have its own parameter list. The Java compiler selects a constructor on its own based on the type of parameters and the number and type of arguments supplied by you.</p>
<p align="center"><strong>Calling One Constructor from Another</strong></p>
<p>The ‘this’ keyword as defined above is used specifically in the case a class has multiple constructors. The ‘this’ keyword is then used to invoke one of the other constructors of the same class. In other words, we can rewrite the two previous Circle constructors as follows:</p>
<p>// This is an example of basic constructor: It is used to initialize the radius</p>
<p>public Circle_class(double radius_var1) { this.radius_var1 = radius_var1; }<span id="more-42"></span></p>
<p>// This constructor uses this () to invoke the constructor above</p>
<p>public Circle_class() { this(1.0); }</p>
<p>The this()keyword is used to invoke methods by calling another constructors of the class. Using the ‘this’ keyword avoids repetition of the code in case of using multiple constructors. This is particularly useful in cases where a large number of constructors share a large amount of initialization code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javahowtoguide.com/java-defining-multiple-constructors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

