khaleel. Powered by Blogger.

ListIterator

Wednesday 22 June 2011

import java.util.*;
public class ListIteratorDemo {
    public static void main(String[] args) {
        LinkedList l=new LinkedList();
        l.add("sharukh");
        l.add("aamir");
        l.add("salman");
        ListIterator li=l.listIterator();
        while(li.hasNext()){
            System.out.println(li.next());
           
        }
        while(li.hasPrevious()){
            System.out.println(li.previous());
        }
    }
}

Read more...

Iterator

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;


public class IteratorArray {

    public static void main(String[] args) {
        ArrayList a=new ArrayList();
        for(int i=0;i<15;i++){
            a.add(i);
        }
        Iterator i=a.iterator();
        while(i.hasNext()){
            System.out.println(i.next());
        }
    }
   
}

Read more...

Enumeration

import java.util.*;
public class EnumerationDemo {

   
    public static void main(String[] args) {
        Vector v=new Vector();
        for(int i=0;i<10;i++){
            v.addElement(i);
        }
        Enumeration e=v.elements();
        while(e.hasMoreElements()){
            Integer g=(Integer) e.nextElement();
            System.out.println(g);
        }
        /*while(e.hasMoreElements()){
            System.out.println(e.nextElement());
        }*/
        }
    }


Read more...

Stack

Tuesday 21 June 2011

import java.util.*;
public class StackDemo {

    public static void main(String[] args) {
        Stack s=new Stack();
        s.push("A");
        s.push("B");
        s.push("C");
        System.out.println(s);
        System.out.println(s.capacity());
        System.out.println(s.search("C"));
        System.out.println(s.search("B"));
        System.out.println(s.search("A"));
        System.out.println(s);

    }

}

Read more...

Vector

import java.util.*;
public class VectorDemo {

   
    public static void main(String[] args) {
        Vector v=new Vector();
        System.out.println(v.capacity());
        for(int i=0;i<10;i++){
            v.add(i);
        }
       System.out.println(v.capacity());
       v.addElement("A");
       System.out.println(v.capacity());
       System.out.println(v);
    }

}

Read more...

LinkedList

import java.util.*;
public class LinkedListDemo {

   
    public static void main(String[] args) {
        LinkedList l=new LinkedList();
        System.out.println("=============");
        System.out.println(l.size());
        l.add("khaleel");
        l.add("khaleel");
        l.add("bhaskar");
        l.add("murali");
        l.add("murali");
        l.add(null);
        l.add(null);
        l.add(new Integer(10));
        System.out.println(l);
        l.set(1, "killer");
        System.out.println(l);
        l.addLast("centris");
        System.out.println(l);
        l.addFirst("hero");
        //l.removeFirst();
        System.out.println(l);
        System.out.println(l.size());
    }

}

Read more...

ArrayList

import java.util.*;
public class ArrayListDemo {

    public static void main(String[] args) {
        ArrayList a=new ArrayList();
        System.out.println(a.size());
        a.add("khaleel");
        a.add("baskar");
        a.add("murali");
        a.add("khaleel");
        a.add(null);
        a.add(new Integer(20));
        a.add(new String("hero"));
        ArrayList b=(ArrayList)a.clone();
        System.out.println(a);
        System.out.println(b);
        System.out.println(a.size());
    }

}

Read more...

Hibernate configuration file to connect Mysql

Friday 17 June 2011

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

    <session-factory>
       
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://192.168.1.101:3306/atrdev</property>
        <property name="hibernate.connection.username">atrdev</property>
        <property name="connection.password">centris</property>
        <property name="connection.pool_size">10</property>
        <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
        <property name="show_sql">true</property>
        <property name="hibernate.hbm2ddl.auto">update</property>
       
        <mapping resource="com/khaleelsoftsol/atr/dao/sessionfactory/AtrEmployeeInfo.hbm.xml"/>
   
    </session-factory>


</hibernate-configuration>

Read more...

Building HelloWorld using Ant

Wednesday 8 June 2011


Building HelloWorld with Ant
The best way to learn Ant is to build a very simple Java class using our build file. We'll need two files for our example: the Java source class and our build.xml file. Open your favorite text editor and enter the code in Listing 16.5 and 16.6. Save your Java file as HelloWord.java, and your Ant file as build.xml.
Listing 16.5 HelloWorld Sample Class
public class HelloWorld{
    public static void main(String []args){
        System.out.println("Hello World!");
    }
}
Listing 16.6 HelloWorld Ant Build File (build.xml)
<project name="HelloWorld" default="compile" >
    <property name="build.dir" value="output"/>
    <target name="init" description="Clean and setup directory">
        <delete dir="${build.dir}"/>
        <mkdir dir="${build.dir}"/>
    </target>
    <target name="compile" depends="init" description="Compile source">
        <javac srcdir="." destdir="${build.dir}"/>
    </target>
</project>
Let's take a line-by-line look at our build file:
  • Line 1: We set the name of our project and the default target.
  • Line 2: We use a user-defined property to store our build output directory name (output in our case).
  • Line 3: We define the first of our two targets. The init target initializes or prepares the output directory.
  • Line 4: We perform a recursive delete on our output directory.
  • Line 5: We create the output directory using our build.dir property. Ant will replace ${"build.dir"} with the value of the build.dir property.
  • Line 7: We define our main target and include a dependency on the init target. This means that the target compile will execute init before it begins its own tasks.
  • Line 8: We use the javac task to call the Java compiler on any .java files located in the current folder. The destdir attribute holds the value of our output directory.
  •  
    All that remains now is to run Ant across our build file. We're using the default filename (build.xml), so there is no need to specify the build file when we invoke Ant. Open a command window and navigate to the folder you saved your sample files in. We've used c:\ant as our source folder, but usually your build root will exist under your main source or project directory. To build HelloWorld, simply type Ant <enter> at the command prompt. You should see output we have displayed in Figure 16.3.
    Figure 16.3. Building HelloWorld with Ant.
    Congratulations, you've built your first application with Ant! You'll find the result of the build, Helloworld.class, in the output directory. We caused Ant to execute the default target (compiler) by not specifying any startup parameters. It's likely that you'll want to call particular targets, such as a release or debug build. In our case, we'll call the init target to clear out the results of our sample build. To do this, we run Ant with
    Ant init
    Figure 16.4 shows Ant running out init target, clearing out the directory structure.
    Figure 16.4. Calling the init target with Ant.

    Finally, we can get a listing that describes the build file by calling Ant with the projecthelp switch. To run this enter the following at the command prompt:
    Ant -projecthelp
    The projecthelp switch causes Ant to parse through your build file and print out the description attributes it finds. Figure 16.5 illustrates the results of executing Ant with projecthelp on our sample build file.
    Figure 16.5. Displaying build file descriptions with Ant.
    Most of this hour has been slanted toward Java development, but we don't want to leave Microsoft readers in the cold! With this in mind, we'll end with some tips to using Ant with Microsoft .NET.

Read more...
Related Posts Plugin for WordPress, Blogger...
Promote Your Blog

About This Blog

This blog is for java lovers

Total Pageviews

About Me

khaleel-bapatla
BAPATLA, ap, India
simple and honest
View my complete profile

  © Blogger template On The Road by Ourblogtemplates.com 2009

Back to TOP