<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Java Programming Forum - Learn Java Programming - Blogs - Core Java</title>
		<link>http://www.java-forums.org/blogs/core-java/</link>
		<description>Java Programming Forum - Learning Java easily</description>
		<language>en</language>
		<lastBuildDate>Wed, 22 May 2013 19:28:18 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.java-forums.org/images/misc/rss.jpg</url>
			<title>Java Programming Forum - Learn Java Programming - Blogs - Core Java</title>
			<link>http://www.java-forums.org/blogs/core-java/</link>
		</image>
		<item>
			<title>Types of Garbage Collector in Java</title>
			<link>http://www.java-forums.org/blogs/core-java/987-types-garbage-collector-java.html</link>
			<pubDate>Fri, 02 Mar 2012 15:31:18 GMT</pubDate>
			<description>Java Runtime provides various Garbage collection types in Java. One may choose them according to the requirements of performance of your application....</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Java Runtime provides various Garbage collection types in Java. One may choose them according to the requirements of performance of your application. In Java 5, three garbage collectors are added except “serial” garbage collector.  Each garbage collector is implemented to raise the throughput of application or to reduce the garbage collection’s pause time.<br />
<br />
<b>1) Throughput Garbage Collector: </b><br />
Garbage collector used parallel version of the Young generation collector. JVM,  -XX:+UseParallelGC option passes via command line, then it is used.Serialcollector and tenured generation collector are same.<br />
<b><br />
2) Concurrent low pause Collector:  </b><br />
This collector is used when–Xingc or  -XX:+UseConcMarkSweepGC pass on command line. Also, it is called “Concurrent Mark Sweep Garbage collector”. Concurrent collector collects tenured generation.Majority of collection gets done with the execution of application. For shorter time duration application is paused during collection. Parallel version of the young generation copying collector and concurrent collector are used along. Concurrent Mark Sweep Garbage collector is widely used in Java. Object required to be collected is 1st marked by algorithm when you trigger garbage collection.<br />
<b><br />
3) The Incremental (Sometimes called train) low pause collector:</b><br />
 Use this collector when -XX:+UseTrainGC passes on command line. Since Java 1.4.2, change has not come in garbage collector. It shall not be used it will not be supported in the future releases.<br />
Don’t use -XX:+UseParallelGC  and -XX:+UseConcMarkSweepGC together.</blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/987-types-garbage-collector-java.html</guid>
		</item>
		<item>
			<title>Garbage Collection Disadvantages</title>
			<link>http://www.java-forums.org/blogs/core-java/986-garbage-collection-disadvantages.html</link>
			<pubDate>Fri, 02 Mar 2012 15:30:05 GMT</pubDate>
			<description>Garbage collection has certain disadvantages which are as following: 
 
 
* Garbage collection uses computing resources so that to take a decision...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Garbage collection has certain disadvantages which are as following:<br />
<br />
<ul><li style="">Garbage collection uses computing resources so that to take a decision that which memory shall be reconstruct or free the fact to which programmer is well-aware of. When object lifetime is not manually annotated in source code, penalty is overhead. It will reduce the performance. Overheads are not bearable or tolerable, when interaction is present to memory hierarchy effects. It is not easy to predict them during routine tests.</li><li style="">Throughout the session, stalls scatter when prediction regarding garbage collection moments could not be made. Such unpredictable kinds of stalls are not being accepted in real time environments, transaction processing or interactive programs.</li><li style="">You can’t have pointer but only references.</li><li style="">Non deterministic garbage collection is non compatible with nonGCed RAII based management of resource. In GC system which is non deterministic when objects are considered as a part of other objects or some resource requires manual resource management, then composed objects are converted to resource objects. Further it will need manual resource management.</li></ul></blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/986-garbage-collection-disadvantages.html</guid>
		</item>
		<item>
			<title>Garbage Collection Overview</title>
			<link>http://www.java-forums.org/blogs/core-java/985-garbage-collection-overview.html</link>
			<pubDate>Fri, 02 Mar 2012 15:28:37 GMT</pubDate>
			<description>Garbage collection is automatic memory management in computer sciences. Garbage collector attempts to reclaim garbage or occupied memory of the...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Garbage collection is automatic memory management in computer sciences. Garbage collector attempts to reclaim garbage or occupied memory of the object that is not in use of program. In 1959, Garbage collection was invented by John McCarthy to solve the Lisp problems.<br />
<br />
Usually garbage collection and manual memory management are considered opposite of each other. Objects are required by programmers which are returned or deallocated to the memory. Various approaches are taken into consideration by number of systems which involve different techniques for example, stack allocation or region inference.<br />
<br />
Garbage collection doesn’t manage limited resources, other than memory that typical programs use for example file and device descriptors, database handles, network sockets and user interaction windows. Methods for management of resources may suffice for memory management which has no GC requirements. Various resources are permitted by GC systems to be lined with the memory region that makes resources to be reclaimed which is often known as finalization.</blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/985-garbage-collection-overview.html</guid>
		</item>
		<item>
			<title>Object Reference Type Casting</title>
			<link>http://www.java-forums.org/blogs/core-java/984-object-reference-type-casting.html</link>
			<pubDate>Fri, 02 Mar 2012 15:27:26 GMT</pubDate>
			<description>In Java object typecasting, type cast of 1 object reference is possible to another object reference. Suck type of casting is done with superclass,...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">In Java object typecasting, type cast of 1 object reference is possible to another object reference. Suck type of casting is done with superclass, subclass or class types. Compile time rules or runtime rules are present in Java for casting.<br />
<br />
Class relationship is the basic thing at which Object reference is dependent. Any object reference could be assigned to reference variable of type object because the object class is usually the superclass, for each Java class.<br />
<br />
Two possible casting java scenarios have been given as under:<br />
<br />
1.	Up-casting<br />
2.	Down-casting<br />
<br />
When casting of referencing is done in some direction with class hierarchy, it is considered as downcast i.e. from root class to subclass. When casting of reference is done in some direction with class hierarchy i.e. from subclass to root, it is considered as upcase. Cast operator is not needed in such kind of case.<br />
Compile time rules catch up attempted casts, in those particular situations where it is not possible. It happens specially attempts are made to cast at objects which are totally un-related. When casted objects are not found compatible with newly casted ones, ClassCastException is thrown.</blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/984-object-reference-type-casting.html</guid>
		</item>
		<item>
			<title>Final Fields and Methods</title>
			<link>http://www.java-forums.org/blogs/core-java/983-final-fields-methods.html</link>
			<pubDate>Fri, 02 Mar 2012 15:20:04 GMT</pubDate>
			<description>Fields and methods might be declared final. For final method possibilities are not there to be overridden, in subclasses. Final field is considered...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Fields and methods might be declared final. For final method possibilities are not there to be overridden, in subclasses. Final field is considered to be constant: Possibility of assigning once again is not present when a value is been provided already. For example, Constructor function of the List class does the item field initialization to size ten array. For array’s initial size, usage of constant is recommendable. For whole class only 1 constant copy is needed. Hence field static as well as final shall be created.<br />
<br />
private static final int INITIAL_SIZE = 10;<br />
<br />
Assignment statement gets changed, in constructor function:<br />
<br />
items = new Object[INITIAL_SIZE];</blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/983-final-fields-methods.html</guid>
		</item>
		<item>
			<title>Static Fields and Methods</title>
			<link>http://www.java-forums.org/blogs/core-java/982-static-fields-methods.html</link>
			<pubDate>Fri, 02 Mar 2012 15:16:30 GMT</pubDate>
			<description>Methods and fields might be declared static. This is also possible for C++. Only one copy is present for the complete class when field is static,...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Methods and fields might be declared static. This is also possible for C++. Only one copy is present for the complete class when field is static, rather than one copy for all class instances. If class instance is not present even then field’s copy is available. For example, given field addition in List class:<br />
<br />
static int numLists = 0;<br />
<br />
And, the given statement addition in the List constructor:<br />
<br />
numLists++;<br />
<br />
When new List object creation takes place, increment of the variable of NumList is done. Hence total created Lists are counted when a program is executed.  All List instances access this variable and similar variable is accessible, not the individual copies.<br />
<br />
Methods need to be static in case accessibility of non static field is not possible. Don’t call non static method. In C++ Free function methods shall be static. Logically associated methods present with a specific class shall be static as well. These methods are involved in manipulation of the Static field class. <br />
<br />
Public static field is accessible by usual notation, outside the class:<br />
<br />
  class-object.field-or-method-name<br />
  <br />
Instead of class object name, class name might be used:<br />
<br />
class-name.field-or-method-name</blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/982-static-fields-methods.html</guid>
		</item>
		<item>
			<title>Fields, Methods, and Access Levels</title>
			<link>http://www.java-forums.org/blogs/core-java/981-fields-methods-access-levels.html</link>
			<pubDate>Fri, 02 Mar 2012 15:13:23 GMT</pubDate>
			<description><![CDATA[* Java classes consist of methods and fields. A field is same as a C++ data member & a method is similar to a C++ member function. 
* Each method &...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><ul><li style="">Java classes consist of methods and fields. A field is same as a C++ data member &amp; a method is similar to a C++ member function.</li><li style="">Each method &amp; field possess an access level:</li></ul><br />
<div style="margin-left:40px">o	private: access is possible in this class only<br />
o	(package): access is possible in this package only<br />
o	protected: access is possible in this package only &amp; also in all subclasses.<br />
o	public: access is possible anywhere this class is present.</div><ul><li style="">Every class consist of these 2 possible access levels:</li></ul><br />
<div style="margin-left:40px">o	(package): class objects can be manipulated &amp; declared only by the help of code present in this package<br />
o	public: class objects might be manipulated &amp; declared by the help of code present in any package.</div></blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/981-fields-methods-access-levels.html</guid>
		</item>
		<item>
			<title>Java Classes</title>
			<link>http://www.java-forums.org/blogs/core-java/980-java-classes.html</link>
			<pubDate>Fri, 02 Mar 2012 15:10:53 GMT</pubDate>
			<description>Various individual objects might be found of same kind, in real work. Thousands of similar bicycles might be present in world that have similar model...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Various individual objects might be found of same kind, in real work. Thousands of similar bicycles might be present in world that have similar model or make. Same components or same blueprints set are used to build bicycles.<br />
<br />
Bicycle may be considered as class bicycle instance, in case of the object oriented programming. Class is basically the blue print which is involved in creation of the individual objects.<br />
<br />
This given Bicycle class is the possible bicycle implementation:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code:  This is the code to explain Java Classes</div>

	<pre class="brush: java">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);
    }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/980-java-classes.html</guid>
		</item>
		<item>
			<title>Java garbage collector</title>
			<link>http://www.java-forums.org/blogs/core-java/763-java-garbage-collector.html</link>
			<pubDate>Sun, 08 Jan 2012 10:53:13 GMT</pubDate>
			<description>A new object is stored into heap when it is created by the Java Program. Heap is also call garbage collectable heap and it can be released by the...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">A new object is stored into heap when it is created by the Java Program. Heap is also call garbage collectable heap and it can be released by the garbage collector. Garbage collector is a JVM low priority thread and its execution cannot be forced. It is executed to release memory allocated to unused object. Also you can ask garbage collector to release memory by using System.gc()<br />
<br />
Object is unreachable when it has no other object that is referencing to this object. In such cases this object is collected and memory is released by the garbage collector. Garbage collector automatically collects all such objects and releases memory used by these objects.<br />
<br />
<div style="text-align: center;"><img src="http://www.java-forums.org/attachments/java-software/2585d1326019946-opengts-1-4-4-62.jpg" border="0" alt="Name:  62.JPG
Views: 188
Size:  37.5 KB" class="thumbnail" style="float:CONFIG" /><br />
<br />
<b>Garbage Collection</b></div></blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/763-java-garbage-collector.html</guid>
		</item>
		<item>
			<title>Type casting</title>
			<link>http://www.java-forums.org/blogs/core-java/762-type-casting.html</link>
			<pubDate>Sun, 08 Jan 2012 10:50:52 GMT</pubDate>
			<description>When you treat a variable of one type to another type, it is called type casting. Up casting supports automatic conversion but in case of low casting...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">When you treat a variable of one type to another type, it is called type casting. Up casting supports automatic conversion but in case of low casting you need to explicitly specify it.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code:  Type Casting</div>

	<pre class="brush: java">byte -&gt; short -&gt; int -&gt; long -&gt; float -&gt; double
int i = 5;
long j = i; //Right. Up casting or implicit casting
byte b1 = i; //Wrong. Compile time error “Type Mismatch”.
byte b2 = (byte) i ; //Right. Down casting or explicit casting is required.</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 In case of objects, you can cast a subclass object into a superclass. <br />
<br />
<div style="text-align: center;"><img src="http://www.java-forums.org/attachments/java-software/2584d1326019808-jcomponentbreadboard-1-0-1-61.jpg" border="0" alt="Name:  61.JPG
Views: 147
Size:  34.6 KB" class="thumbnail" style="float:CONFIG" /><br />
<br />
<b>Upcasting vs Downcasting</b></div></blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/762-type-casting.html</guid>
		</item>
		<item>
			<title>Outer and Inner classes</title>
			<link>http://www.java-forums.org/blogs/core-java/761-outer-inner-classes.html</link>
			<pubDate>Sun, 08 Jan 2012 10:47:38 GMT</pubDate>
			<description>All the classes in Java are not defined separately from other classes. You can also write one class into another class. The inside class is referred...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">All the classes in Java are not defined separately from other classes. You can also write one class into another class. The inside class is referred as inner class and the class containing this inner class is called outer class. Inner class is a member of outer class similar to other attributes and methods. <br />
<br />
Avoid using inner classes when they are not required. It is hard to maintain and reuse code with inner classes. Only use it when it is required and relevant. They are used usually to implement helper classes like Comparators and Iterators.<br />
<br />
<div style="text-align: center;"><img src="http://www.java-forums.org/attachments/new-java/2582d1326019620-deleting-certain-image-pixels-59.jpg" border="0" alt="Name:  59.JPG
Views: 54
Size:  17.2 KB" class="thumbnail" style="float:CONFIG" /><br />
<br />
<b>Outer and Inner classes</b></div></blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/761-outer-inner-classes.html</guid>
		</item>
		<item>
			<title>Java stack and heap memory</title>
			<link>http://www.java-forums.org/blogs/core-java/760-java-stack-heap-memory.html</link>
			<pubDate>Sun, 08 Jan 2012 10:43:55 GMT</pubDate>
			<description>Heap is used to store new objects created by Java. Stack is used to store primitive data types like int and double when they are declared locally....</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Heap is used to store new objects created by Java. Stack is used to store primitive data types like int and double when they are declared locally. These primitive data types are stored on heap when they are declared globally. Whenever a Java method is called, all the local variables are pushed to stack and its pointer is decremented after completion of that method call. In a multithreaded application only one heap is used and each thread contains its own stack. So do not declare your data globally that will be placed on heap and updated by multiple threads to avoid sybchronization issues. Heap is not thread safe as compare to stack which is thread safe.<br />
<br />
<div style="text-align: center;"><img src="http://www.java-forums.org/attachments/eclipse/2581d1326019402-cannot-create-new-jboss-configuration-eclipse-58.jpg" border="0" alt="Name:  58.JPG
Views: 1230
Size:  35.9 KB" class="thumbnail" style="float:CONFIG" /><br />
<br />
<b>Java stack and heap memory</b></div></blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/760-java-stack-heap-memory.html</guid>
		</item>
		<item>
			<title>Using Imports to Change Behaviour</title>
			<link>http://www.java-forums.org/blogs/core-java/613-using-imports-change-behaviour.html</link>
			<pubDate>Tue, 29 Nov 2011 02:24:02 GMT</pubDate>
			<description>One thing that would be great to have is a feature that I know well from my previous experience coding in C. That is the possibility to conditional...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">One thing that would be great to have is a feature that I know well from my previous experience coding in C. That is the possibility to conditional compile in order to modify the behaviour of the application. A feature that is missing from Java is C’s conditional compilation, which allows you to change a switch and get different behaviour without changing any other code.  I think is was left out of Java is that I remember using this feature often to address issues related to compiling a program on different platforms. As java was built to be cross-platform, I guess they deemed such a feature to be unnecessary.<br />
<br />
There are still other valuable uses for conditional compilation such as for debugging. It would be very straightforward to be able to enable features for debugging during development and disable them for a production. Now I discovered that a way to move from debug to production versions of a package is to change the package being imported. This is a technique that I use quite often when going from simulated to real versions of packages with which I need to integrate.</blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/613-using-imports-change-behaviour.html</guid>
		</item>
		<item>
			<title>Managing Initialization and Class Loading</title>
			<link>http://www.java-forums.org/blogs/core-java/612-managing-initialization-class-loading.html</link>
			<pubDate>Tue, 29 Nov 2011 02:20:47 GMT</pubDate>
			<description>Java avoids many of the problems found with other languages related to the startup and initialization of objects in the right order, by taking a...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Java avoids many of the problems found with other languages related to the startup and initialization of objects in the right order, by taking a different approach to loading. The key to this is that everything in Java is an object. Each class exists in its own separate file. Therefore files are not loaded until the code is needed. The expression of this is that “class code is loaded at the point of first use.” This is usually when the first object of that class is constructed, but loading also occurs when a static field or static method is accessed.<br />
<br />
Static initialization always takes place at the point of first use. All the static objects and the static code block will be initialized in  the order that they are defined in the class definition when they are loaded. Statics are initialized only once. In the example below, I will demonstrate the initiation process showing both static initialization and inheritance.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">import static com.acme.examples.Print.*;

public class MyBase {
	private int i = 9; protected int j; 
	MyBase() {
		print(&quot;i = &quot; + i + &quot;, j = &quot; + j); 
		j = 39;
		} 
	
	private static int x1 =
		printInit(&quot;static MyBase.x1 initialized&quot;); 
		static int printInit(String s) {
			print(s);
			return 47;
		}
}


import static com.acme.examples.Print.*;

public class MyExtended extends MyBase {
	private int k = printInit(&quot;MyExtended.k initialized&quot;);

	public MyExtended() {
		print(&quot;k = &quot; + k);
		print(&quot;j = &quot; + j);
	}

	private static int x2 = printInit(&quot;static MyExtended.x2 initialized&quot;);

	public static void main(String&#91;&#93; args) {
		print(&quot;MyExtended constructor&quot;);
		MyExtended myE = new MyExtended();
	}
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 When you launch MyExtended the first method that will be accessed is MyExtended.main( ) (a static method), so the loader goes out and finds the compiled code for the MyExtended class (in the file MyExtended.class). While loading it, the loader realizes that it has a base class (MyBase), which it then loads. This will happen irrespective of whether you will make an object of the base class. The next part is the static initialization in the root base class (MyBase) is performed, and then any static initialization in the derived class. This is because the derived-class static initialization could depend on the base class member being initialized.<br />
<br />
When all the necessary classes have been loaded, the object can be created. The order is the following; 1. All the primitives in this object are set to their default values; 2. Object references are set to null; 3. The base-class constructor is called (Either automatically, or by calling the constructor); 4. The base class construction goes through the same process in the same order as the derived-class constructor; 5. After the base-class constructor completes, the instance variables are initialized in textual order. 6. The rest of the body of the constructor is executed.</blockquote>

]]></content:encoded>
			<dc:creator>Core Java</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/core-java/612-managing-initialization-class-loading.html</guid>
		</item>
	</channel>
</rss>
