Powered by Blogger.
Showing posts with label Examples. Show all posts
Showing posts with label Examples. Show all posts

4 Ways to Reverse an Array in Java

>> Wednesday, August 20, 2014

Explain 'different ways to reverse an array' is one of the famous java interview questions. Using an array in programming is common with primitive types like e.g. int, long, double and String arrays to perform some operations. But to understand quickly we are using integer array with numbers to reverse. Actually we should know different types of arrays and how to iterate them. The basic programs on adding two matrices and multiplication of matrices is important .
four ways to reverse an array in java_JavabynataraJ

Read more..

Simple Hibernate Example on Inserting Employee details using MySql

>> Wednesday, May 25, 2011

Hibernate is a solution for object relational mapping and a persistence management solution or persistent layer. This is probably not understandable for anybody learning Hibernate.

What you can imagine is probably that you have your application with some functions (business logic) and you want to save data in a database. When you use Java all the business logic normally works with objects of different class types. Your database tables are not at all objects.

Hibernate provides a solution to map database tables to a class. It copies the database data to a class. In the other direction it supports to save objects to the database. In this process the object is transformed to one or more tables.

Read more..

Upload CSV file into MySql Database based on columns using Servlets and Java

>> Tuesday, April 12, 2011

The CSV file is having multiple values to insert in perticular columns and rows in mysql database.

Here we have two files so we have to insert in two tables .

one is Header part file

another is Detail part file

Basically these two are to upload the questions and answers into the examination portal to upload question papers and answer paper in (Merit Tracking System project).

First we have to do the things are Uploaded file has to save in perticular folder and then they have to insert the values into the database table.This is our main task to do.

Read more..

Example to find maxmimum element in a Vector

>> Sunday, October 17, 2010

Example to find maximum element in a Vector

This java example shows how to find a maximum element of Java Vector using max method of Collections class.To find maximum element of Java Vector use, static Object max(Collection c) method of Collections class.

This method returns the maximum element of Java Vector according to its natural ordering.

    import java.util.Vector;
    import java.util.Collections;

    public class FindMaximumOfVectorExample {
     public static void main(String[] args) {

     //create a Vector object
     Vector v = new Vector();
     //Add elements to Vector
 
     v.add(new Double("324.4324"));
     v.add(new Double("345.3532"));
     v.add(new Double("342.342"));
     v.add(new Double("357.349"));
      v.add(new Double("23.32453"));

      Object obj = Collections.max(v);
     System.out.println("Maximum Element of Java Vector is : " + obj);

     }
    }


The Output is:

Maximum Element of Java Vector is : 357.349

Reference Books:

Read more..

Example to Find maxmimum element in ArrayList

Example to Find maxmimum element in ArrayList

This java example shows how to find a maximum element of Java ArrayList using max method of Collections class.

To find maximum element of Java ArrayList use, static Object max(Collection c) method of Collections class.
This method returns the maximum element of Java ArrayList according to its natural ordering.

import java.util.ArrayList;
    import java.util.Collections;

    public class FindMaximumOfArrayListExample {

     public static void main(String[] args) {

     //create an ArrayList object
     ArrayList arrayList = new ArrayList();

     //Add elements to Arraylist
     arrayList.add(new Integer("327482"));
     arrayList.add(new Integer("13408"));
     arrayList.add(new Integer("802348"));
     arrayList.add(new Integer("345308"));
     arrayList.add(new Integer("509324"));

     Object obj = Collections.max(arrayList);
     System.out.println("Maximum Element of Java ArrayList is : " + obj);

     }
    }

The Output :

Maximum Element of Java ArrayList is : 802348

Reference Books: 

Read more..

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2022. All rights reserved.