View RSS Feed

All Blog Entries

  1. Array Store Exception

    by , 03-04-2012 at 11:18 AM
    If array variable v consists of type A[] (where A is a reference type) then v might hold a reference to any array type B[] instance.( provided that B could be assigned to A).

    Java Code:
    class Point { int x, y; }
    class ColoredPoint extends Point { int color; }
    class Test {
    	public static void main(String[] args) {
    		ColoredPoint[] cpa = new ColoredPoint[10];
    		Point[] pa = cpa;
    		System.out.println(pa[1] == null);

    Updated 03-04-2012 at 11:21 AM by Java Array

  2. Class Objects for Arrays

    by , 03-04-2012 at 11:17 AM
    An associated class object is present for every array that is shared to other arrays along with similar component type.An array’s direct superclass is Object. Interfaces and Cloneable are implemented by every array type.

    Following example code could better explain this:
    Java Code:
    class Test {
    	public static void main(String[] args) {
    		int[] ia = new int[3];
    Tags: object array Add / Edit Tags
    Object Array
  3. Array Initializers

    by , 03-04-2012 at 11:14 AM
    In a declaration, an array initialize might be specified. It also might be specified as an array creation expression part, that gives certain initial values and creates an array.

    { VariableInitializersopt ,opt }

    VariableInitializers , VariableInitializer

    To make it further clear:

  4. Array Variables

    by , 03-04-2012 at 11:12 AM
    Reference to object is being held by the array type variable. Declaration of a variable of array type doesn’t allocate space for the array components or create the array object. But, declarator’s initializer part may make an array and a reference which will become variable’s initial value.

    Array length is not considered as a part of its type therefore an array type’s single variable might possess reference to other array of varying length.

    Given below are few examples ...
  5. Array Types

    by , 03-04-2012 at 11:10 AM
    To write an array type use element type name with few empty square bracket pairs[]. Depth of array nesting is indicated by the no. of bracket pairs. Length of array is not its type part.

    An array’s element type might be any type whether reference or primitive. Particularly,

    • Arrays along with an interface type, as the component type are allowed. Such array’s elements might use null reference as their value or any type instances which implements interface.
    • Arrays
    Tags: array types Add / Edit Tags
  6. Copying Arrays

    by , 03-04-2012 at 11:08 AM
    An arraycopy method is used by the system class which can efficiently be used to copy one array’s data to other:

    Java Code:
    public static void arraycopy(Object src,
                           int srcPos,
                           Object dest,
                           int destPos,
                           int length)
    The array to copyfrom or the array to copyto is specified by the two object arguments. Three int arguments are used for the specification ...
  7. Creating, Initializing, and Accessing an Array

    by , 03-04-2012 at 11:05 AM
    One can create an array by the help of the new operator. In ArrayDemo program, next statement allocates the array along with quite enough memory. This is done for 10 integer elements so that to assign array to anArray variable.

    Java Code:
    // create an array of integers
    anArray = new int[10];
    In case if the given statement is missing, an error like this would be printed by compiler and also the compilation would fail.

    To array’s each element, ...
  8. Declaring a Variable to Refer to an Array

    by , 03-04-2012 at 11:02 AM
    Array is declared in the above program along with this line of code.
    Java Code:
    // declares an array of integers
    int[] anArray;
    Array declaration also consists of 2 components, just like other declarations for other types of variables. They are
    • Array’s name
    • Array’s type

    Array’s type is written as type[].

    An array’s name could be anything that you may want provided it follows the conventions. Just like other type variables, array ...
    Tags: refer array Add / Edit Tags
  9. Java Array

    by , 03-04-2012 at 11:00 AM
    Array is that container object which consists of fixed value numbers of one single type. When array is created, establishment of the length of an array takes place. Length is fixed after creation of an array. In Hello world application’s main method, example of array has already been given. Here detailed array section will be given.

    Name:  1.JPG
Views: 512
Size:  10.5 KB
    An array of ten elements

    Every item present in array is known as an element. Numerical index is used ...
    Tags: java array Add / Edit Tags
  10. Drools Components

    by , 03-04-2012 at 10:57 AM
    1. Rules – Where conditions are specified (If a then b)
    2. Facts – Simple objects (POJOs). E.g, a Bank Account fact consists of an account number, someone’s id and balance.
    3. Knowledge Base –is where rules are built and loaded into a structure that gets implemented by the Rete algorithm.
    4. Session – Here facts are placed. Facts are inserted into a session. A session can be State less or State full. Facts in the statefull shall be present in a constant rule alignment once ...
    Drools Rules
  11. How is JBoss Drools is made up

    by , 03-04-2012 at 10:54 AM
    There are 2 main parts of Drools:

    Authoring & Runtime

    Creation Rules files (.DRL) are involved in authoring process. They consists of rules that are being fed to a parser. Correct syntax of rules is checked by parser which creates intermediate structure so that to describe certain rules. Then it is passed on to Package Builder that creates the packages. After this, any code generation as well as compilation is undertaken that is essential to create package.
    Tags: jboss drools Add / Edit Tags
    Drools Rules
  12. Why using a Rule Engine ?

    by , 03-04-2012 at 10:53 AM
    Rule systems are able to solve hard problems by providing the detail of the arrival of the solution and also why every decision was been taken along the way.

    Major benefits of Rule Engine are:

    Logic & Data Separation
    To break down the domain objects from business rules could make it possible to easily maintain the application. This is possible because it may shield from the future alterations.

    Speed & Scalability
    Several times, “if” ...
    Tags: rule engine Add / Edit Tags
    Rule Engine
  13. Drools Components and Terminology

    by , 03-04-2012 at 10:51 AM
    Objects used by the Drools are market out by the rules and patterns which are responsible for invoking the certain actions:

    • Drool objects are considered as the Java objects. They are usually presented by the XML schemas or instances of the Java classes.
    • A patter being a coded expression is involved in the manipulation of 1 or more than 1 objects so that to create a pattern for making, adapting behavior, according to the designed logic.
    • Working Memory drools stores its objects
    Drools Rules
  14. Advantages of the Drools rule engine

    by , 03-04-2012 at 10:48 AM
    Drools rule engine offers these advantages.
    • It separates conditions and applications

    • They are present in separated files
    • Different people groups can modify them
    • After changing a rule, recompilation is not needed. Redeployment is also not needed in the whole application.
    • To control an application’s flow, put rules at one place
    • All the complexed statements can be replaced by rules in an easier or understandable way

    • Rule language is not tough to be learnt.
    • An
  15. Drools Overview

    by , 03-04-2012 at 10:46 AM
    Drools, BRMS i.e. business rule management system consists of a forward chaining inference based rule engine. Correctly, it is called production rule system which uses enhanced Rete algorithm implementation.
    For its business rule engine as well as its enterprise framework, Drools provides support to JSR-94 standard. This is done for maintenance, construction & enforcement of organization’s business policies, services or applications.

    Pluggable language implementations are ...
    Tags: drools Add / Edit Tags
  16. Self Made Observable Pattern

    by , 03-03-2012 at 11:50 PM
    Java Code:
    package observerPatternSelfMade;
    public class MyObservableClass implements MyObservableInterface {
    	public void registerObserver(MyObserverInterface o) {
    	public void removeObserver(MyObserverInterface o) {
    	public void notifyObservers() {
    		for(int i = 0; i<observers.size();i++)
  17. Strategy Pattern Example

    by , 03-03-2012 at 11:20 PM
    Java Code:
    package strategyPattern;
    public class Warrior {
    	private AttackBehaviour attackBehaviour;
    	public String name;
    	void setAttackBehaviour(AttackBehaviour aB) {
    		this.attackBehaviour = aB;
    	void attack() {
    package strategyPattern;
    public interface AttackBehaviour {
    	void attack();
  18. Using the Observable - Observer class , interface in JAVA. Observer Pattern example.

    by , 03-03-2012 at 11:00 PM
    Java Code:
    package observerPatternBuiltIn;
    import java.util.Observable;
    public class MyObservable extends Observable {
    	int integerToBeObserved;
    	public void setInt(int i) {
    		integerToBeObserved = i;
    	public int getInt() {
    		return integerToBeObserved;
    package observerPatternBuiltIn;
  19. Decorator Pattern Example

    by , 03-03-2012 at 10:27 PM
    Java Code:
    package decoratorPattern;
    public abstract class Beverage {
    	String description;
    	int size;
    	public Beverage(int size) {
    		this.size = size;
    	public String getDescription() {
    		String mySize = null;
    		if(size == 1)
    			mySize = "Small";
    		else if(size==2)
    		else if(size==3)
  20. How to set value to entity?

    by , 03-03-2012 at 08:42 AM
    Quote Originally Posted by heart_throbber View Post
    Hi all,
    I have 2 DTOs & 2 Entities, 1 controller & 1 service implementation over here.

    Now, my problem is at the service implementation setStates. I dont know how to set states to address entity from addressDTO's getStatesList. because address entity includes state entity while addressDTO using stateDTO .

    My Address Entity:
    Java Code:
    public class Address
        private List<State> states;
        public List<State>
  21. Types of Garbage Collector in Java

    by , 03-02-2012 at 05:31 PM
    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.

    1) Throughput Garbage Collector:
    Garbage collector used parallel version of the Young generation collector. JVM, -XX:+UseParallelGC ...
  22. Garbage Collection Disadvantages

    by , 03-02-2012 at 05:30 PM
    Garbage collection has certain disadvantages which are as following:

    • 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
  23. Garbage Collection Overview

    by , 03-02-2012 at 05:28 PM
    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.

    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 ...
  24. Object Reference Type Casting

    by , 03-02-2012 at 05:27 PM
    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.

    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.

    Two ...
    Tags: type casting Add / Edit Tags
  25. Final Fields and Methods

    by , 03-02-2012 at 05:20 PM
    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 ...
    Tags: final fields Add / Edit Tags
  26. Static Fields and Methods

    by , 03-02-2012 at 05:16 PM
    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:

    static int numLists = 0;

    And, the given statement addition in the List constructor:


    When new List object creation takes ...
  27. Fields, Methods, and Access Levels

    by , 03-02-2012 at 05:13 PM
    • 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 & field possess an access level:

    o private: access is possible in this class only
    o (package): access is possible in this package only
    o protected: access is possible in this package only & also in all subclasses.
    o public: access is possible anywhere this class is present.
    • Every class consist of these
  28. Java Classes

    by , 03-02-2012 at 05:10 PM
    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.

    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.

    This given Bicycle class is the possible bicycle implementation: ...
    Tags: java classes Add / Edit Tags
  29. Plain Text Emails

    by , 03-01-2012 at 07:22 PM
    I am trying to send a plain text email via XSL. The problem I am facing is including an ampersand ("&") in an Url link.

    So i am trying in the following manner :

    <a href>"ankit"&amp;b="agarwal"</a>

    So when I this link in a plain text email its shows like this:"ankit"&amp;b="agarwal"

    instead of :
  30. How to get e-mail with Java

    by , 02-29-2012 at 04:39 PM
    In the article “How to send e-mail with Java”, you are familiar with the JavaMail API on sending e-mail messages from a SMTP server. What about receiving e-mail messages? Well, that is the topic of this article. We will study how the JavaMail API exposes classes and interfaces for retrieving e-mail messages from a server, to write a utility class that checks for new messages in inbox of an e-mail account from Gmail server.

    Protocols for receiving e-mail

    There are two ...
    Mail API
Page 19 of 48 FirstFirst ... 9171819202129 ... LastLast