Monday, February 29, 2016

Java - Method Overloading, simple example.



Method Overloading is concept of having same NAME for different methods
in a class performing different but closely related tasks.

For instance, addition is a task, where we may have different methods
for adding integers, decimal and their combinations.
Similarly we may have display methods separately for numbers and strings.

Now,
Methods have signature that enable compiler to distinguish one from another.
The signature of a method constitutes -
Name, No.of arguments, order of arguments and data type.
Note: Return Type is not part of signature, so change in it do not make it
distinct.
So, when we have SAME name for different  methods present in a same class,
we must make distinction in other elements of the signature.
We can have Different no. of arguments/Order of arguments/Data type.
The point is, each overloaded method must be distinct from one another,
so that compiler can identify them uniquely.



Program :

class DisplayMethods {
    String ps = "\nPrice :"; // string literals to avoid retyping
    String cs = "\nCamera :";
    
    /* 3 Methods having the same name 'Dis' with different no. of parameters */
     void Dis(String type, int price){
       System.out.println(type + " - "+ ps + price);
        
    }
      void Dis(String type, String camera, int price){
             System.out.println(type + " - " + cs + camera + ps + price);
              
    }
       void Dis(String type, String camera, String flash, int price){
           System.out.println(type + " -  " + cs + camera + "\nFlash : " + flash + ps + price);
      
        
    }
}
public class Overloading {

    public static void main(String[] args) {
       
        DisplayMethods dm = new DisplayMethods();// Object & Instant Creation

        dm.Dis("Base Phone", 100);
        dm.Dis("Camera Phone", "5 MP RC" ,500);
        dm.Dis("Camera Phone with Flash", "8 MP RC", "LED Flash", 1000);
    }
    
}

Output :

run:
Base Phone - 
Price :100
Camera Phone - 
Camera :5 MP RC
Price :500
Camera Phone with Flash -  
Camera :8 MP RC
Flash : LED Flash
Price :1000

Sunday, February 28, 2016

Java - Inheritance and Method Overriding, simple example



Inheritance means one class deriving attributes and methods from another class.
The class that inherits is called a subclass and the class from which it inherits
is called as superclass.
In other words, if two classes have common attributes and methods between them.
Those common elements need not be coded in each of the classes but can be shared.
In Java by using the 'extends' keyword while defining the subclass,
those common elements can be extended from the superclass to the subclass

Let us take an easy example.
We have cellphones of different types
Basic cellphone - one can make only calls
Cellphone with camera - one can make calls and also take pictures.
Cellphone with Flash Camera - one can make calls and take pictures in day and night.

But, all the three types have one common element which is making calls.
And the last two cell phones have common elements Camera
but with different functionalities.
We will see, how to implement inheritance and also method overriding.

Program : 

/* CellPhone class has two methods
   'Call' method to print the type of the phone
   'price' method which takes price as argument and prints it*/

 class CellPhone {
  int price;
    void call(){
        System.out.println( "With this cell you can make calls");
    }
   void price(int p){
      System.out.println( "Price : "+ p);
     
   }
}

/* CameraCellPhone as subclass inherits 'call' and 'price' method  from the 
   superclass CellPhone.
  Method 'camera' defined in this class prints "take pictures in day time only".
 */

class CameraCellPhone extends CellPhone{
       void camera(){
       System.out.println("take pictures in day time only");
   }
}

/* FlashCameraCellPhone inherits 'call', 'price' and 'camera' method 
   from superclass  CameraCellPhone.
   But, if you notice, 'camera' method prints 'take pictures only in day time',
   Which would be wrong for Flash Camera class.
   so, using the same name Camera, we define a method which prints
   " take pictures in day and night".
   This is called method overriding.
   That is 'camera' method in the subclass overrides the 'camera' method in the superclass
*/
   class FlashCameraCellPhone extends CameraCellPhone{
     
       void Camera(){
           System.out.println ("take pictures in day and night");
        
       }
   }

/* Main Program */

public class Inheritance {

        public static void main(String[] args) {
      
        CellPhone cp = new CellPhone();
        CameraCellPhone ccp = new CameraCellPhone();
        FlashCameraCellPhone fccp = new FlashCameraCellPhone();

        /* out put from Cell Phone object */

        System.out.println("[1] Basic Cell Phone");
        cp.call();
        cp.price(100); // calling price method with 100 as argument

        /* out put from CameraCellPhone Object */

        System.out.println("[2] Camera Cell Phone");
        ccp.call();
        ccp.camera();
        ccp.price(500); 

        /* out put from FlashCameraCellPhone object */

        System.out.println("[3] Flash Camera Cell Phone ");
        fccp.call();
        fccp.Camera();  // Java executes the subclass method (fccp.Camera()),
                                  // since it is available and overrides the superclass
                                 // (ccp.camera()) method
        fccp.price(700); 
          
       
    }
     
}

Output :
run:
[1] Basic Cell Phone
With this cell you can make calls
Price : 100
[2] Camera Cell Phone
With this cell you can make calls
and take pictures in day time only
Price : 500
[3] Flash Camera Cell Phone
With this cell you can make calls
and take pictures in day and night
Price : 700



Basic Overriding Rule :  Name,order of arguments, return type of both
                                           overridden and overriding method must be the same

Friday, February 26, 2016

Java - Program Structure ( Class, Object and Method) for beginners



Java is an Object Oriented (OO) programming language.
That is
Software objects/entities like Employee, Product, Customer etc are 
conceptualized as objects in Java.
To understand that, let us see how we deal with objects in our life.
In our daily life
We identify objects by their attributes/properties and working methods
 / behavior.
A fridge is identified by its features(attributes) and how it is used (methods).
So are animals, their features( 4 legs, tail etc) and 
how they behave (barks, mews or runs etc ).
Similarly
If we take a software object like product’ ,
 its name, price can be its Attributes and 
formula for calculating depreciation/discount can be its Methods. 
Based on these , a product object is conceptualized.
Important point is,
An object is combination of  Attributes and Methods.
They are not separate but stated together. 
Let us take a simple example of the geometrical figure Rectangle.
Length and Breath are its attributes.
formula to calculate Area is a Method. 
We can have  many methods depending on the context.
When we say Rectangle Object, it includes length,breath and

the formula for area.

We can write it this way,
Rectangle
Attributes
Length (Integer Type)
Breath (Integer Type)
Method
Area (Integer Type)        = Length*Breath

Now,

When  the above object structure is translated into Java, 

it is called as Class.

Because it is only a structural definition of an object, 

not an object itself in Java.

Using this class as template, real objects are created in Java.

The basic difference between Java Class and Object  is,

objects are allocated memory during run time and they carry data.

There could be many  Rectangle Objects with different length and breath

but there is only one Rectangle Class based on which they are created.
So, in Java, Class of Rectangle have the following details;
Class Rectangle
Attributes
Length (Integer Type)
Breath (Integer Type)
Method
Area (Integer Type)        = Length*Breath
If we use the Java language syntax it will be like this
   class Rectangle{ 
        int breath ;
        int length;   
    void circumference (){       
        int area = breath*length;
                       }
               }
Entire program would have more statements and information  as below.

Though this post is only about concepts and not about Java coding,

explanation for each statement is given as comments in the following

example for understanding. 

Program:


package clsobjmthd; // package name

/* Coding of the Rectangle Class */
 class Rectangle{ 
             int breath =10;
             int length = 15;
   
     void FindArea (){ //method is void because it does not return value
       
        int area = breath*length;
        System.out.println("Area : " + area); // print statement to display result
     
    }

/* End of Rectangle Class */

public class ClsObjMthd { 

    public static void main(String[] args) { // Java runs the Main first
       
        Rectangle RectObj; // Creating a object using the class

        RectObj = new Rectangle(); // Creating an instance -allocates memory

        RectObj.FindArea(); // calling the method,

                                        //Method is qualified by the object to which it 
                                          belongs by '.'
       
    } 


      
Output:

run:

Area : 150

Initially for a beginner, the structure may appear bit odd or confusing 

but one will be able  appreciate the OO structure as one gain experience.

Bottom line is, in Java, one has to think in terms of Class, Object

and Method.

Let us look at this statement as example 
A customer talks about discount on a product with a salesman.
Here, we can identify objects and methods.
Objects - Customer, Salesman, Product
Method - Discount Procedure and it could be associated with Product.
Then, we can move into detail and club attributes and methods of an object .
By working on various examples, one can get hold on this concept.

Rest is, how we translate it into Java language.




Tuesday, February 23, 2016

Java Thread - simple program by extending the Thread class


Concept of Thread refer to running many processes(subprograms) concurrently
within a Main program.

As simple illustration.
If COOKING a dish is the Main program.
Within it, Heating Oil and Cutting Vegetables are independent tasks.
There is no need to wait to cut vegetables till Oil is heated.
Theses two tasks can be performed concurrently by assigning them two people.

Same thing can be done in java by assigning the tasks to two threads.

We will use the above example and write a Java program with
COOKING as a the Main program and
HEATING OIL and CUTTING VEGETABLE as two threads running concurrently
within the Main program.

In Java, Thread can be created in two ways.

1. Using the RUNNABLE interface
2. By extending THREAD class.

This programs uses extended THREAD class.
The classes overrides run() method.
run() method contains content of the thread.
Threads end when run() method is completed.


/* HeaingOil thread class*/

class HeatingOil extends Thread{
   int HOcount;
      public void run() {
   
        while(HOcount <= 5){
            try{
                System.out.println("Mts "+(++HOcount) +"- Heating  Oil");
         
                Thread.sleep(1000);
         
            } catch (InterruptedException ie) {
                System.out.println("Exception in thread: "+ie.getMessage());
           }
        }
   
      }
}

/* CuttingVegetable Thread class */

class CuttingVegetable extends Thread{
   int VCcount;
      public void run() {
   
        while(VCcount <= 5){
            try{
                System.out.println("Mts "+(++VCcount) +"- Cutting Veg.");
         
                Thread.sleep(1000);
         
            } catch (InterruptedException ie) {
                System.out.println("Exception in thread: "+ie.getMessage());
           }
        }
   
      }
}

/* Main Program */

public class Cooking {

    public static void main(String[] args) {
         HeatingOil hot=new HeatingOil();   // Object instances of thread classes
         CuttingVegetable cvt = new CuttingVegetable();
     hot.start();                                           // Starting the threads
     cvt.start();
      while (cvt.isAlive() && hot.isAlive()){ //Loops till threads ends
       
                try{
                     Thread.sleep(1000);
   
            } catch (InterruptedException ie){
                System.out.println("Exception in main thread: "+ie.getMessage());
            }
       
    }
 
       System.out.println("CUTTING VEG. IS OVER");
           System.out.println("HEATING OIL IS OVER");
          System.out.println("Main Program COOKING proceeds...");
    }
}

Output -
run:
Mts 1- Heating  Oil
Mts 1- Cutting Veg.
Mts 2- Heating  Oil
Mts 2- Cutting Veg.
Mts 3- Heating  Oil
Mts 3- Cutting Veg.
Mts 4- Heating  Oil
Mts 4- Cutting Veg.
Mts 5- Cutting Veg.
Mts 5- Heating  Oil
Mts 6- Cutting Veg.
Mts 6- Heating  Oil
CUTTING VEG. IS OVER
HEATING OIL IS OVER
Main Program COOKING proceeds...

Click to Thread Creation using RUNNABLE interface

Java Thread - simple program using Runnable Interface



Concept of Thread refer to running many processes(subprograms) concurrently
within a Main program.

If we consider the Main program as a JOB,
the job can be divided into different tasks and
the tasks which are independent can be processed concurrently
using threads within that Main program.

As simple illustration.
If COOKING a dish is the Main program.
Within it, Heating Oil and Cutting Vegetables are independent tasks.
There is no need to wait to cut vegetables till Oil is heated.
Theses two tasks can be performed concurrently by assigning them two people.

Same thing can be done in java by assigning the tasks to two threads.

We will use the above example and write a Java program with
COOKING as a the Main program and
HEATING OIL and CUTTING VEGETABLE as two threads running concurrently
within the Main program.

In Java, Thread can be created in two ways.

1. Using the RUNNABLE interface
2. By extending THREAD class.

This programs uses RUNNABLE interface.
Runnable interface consists of one method run(), which is executed when
the thread is activated by start() method.
run() method contain the program content of the thread.
Thread automatically ends when run() is completed.

Now,
We create two Runnables, one for the task of Heating Oil and another
for Cutting Vegetables.
The content for each thread (runnables) must be coded in the run() method of
respective runnable class.
After creating the Runnable classes.
In the Main program, Objects are created from the classes.
And, threads are constructed using the objects.
Exception for the threads are caught using InterruptedException, which is
extension of Exception class.


/* HeatingOil Runnable */

class HeatingOil implements Runnable{
 public static int HOcount; // counter for iteration
 
    public HeatingOil(){
     
       
    }
    public void run() {
   
        while(HOcount <= 5){
            try{
                System.out.println("Mts "+(++HOcount) +"- Heating  Oil");
         
                Thread.sleep(1000);
         
            } catch (InterruptedException ie) {
                System.out.println("Exception in thread: "+ie.getMessage());
           }
        }
    }
}

/* CuttingVegetable Runnable */

class CuttingVegetable implements Runnable{

    public static int CVcount;
    public CuttingVegetable(){
       
    }
    public void run() {

        while(CuttingVegetable.CVcount <= 5){
            try{
         
                System.out.println("Mts "+ (++CVcount) + "- Cutting Vegetables " );
     
                Thread.sleep(1000); // suspending thread
            } catch (InterruptedException ie) {
                System.out.println("Exception in thread: "+ie.getMessage());
            }
           
        }
    }
}

/* In the Main program. 
Using the above Runnables corresponding objects are created (HeatingOil,CuttingVegetable).
And for each runnable objects, a thread is constructed ( hot, cvt).
Threads have many methods, methods used in this program are
start() - to start the Thread and it also implicitly executes the run() method.
sleep(n) - to suspend thread for said time
isAlive(t)- to check whether the thread is completed the run() method.
A thread end automatically after completing the run() method.

*/
public class Cooking {

 
    public static void main(String[] args) {

        System.out.println("Main Thread...");
        HeatingOil ho = new HeatingOil(); // object creation
        CuttingVegetable cv = new CuttingVegetable();
        Thread hot = new Thread(ho); //thread construction
        Thread cvt = new Thread(cv);
        hot.start(); // Starting the threads and it will execute the run()
        cvt.start(); // implicitely
       
        // loops till both the threads end 
     while (cvt.isAlive() && hot.isAlive()){
       
                try{
                     Thread.sleep(1000);
   
            } catch (InterruptedException ie){
                System.out.println("Exception in main thread: "+ie.getMessage());
            }
         
         
         }
           
          System.out.println("CUTTING VEG. IS OVER");
           System.out.println("HEATING OIL IS OVER");
          System.out.println("Main Program COOKING proceeds...");
     
    }
 
}

Output :

run:
Main Thread...
Mts 1- Heating  Oil
Mts 1- Cutting Vegetables
Mts 2- Heating  Oil
Mts 2- Cutting Vegetables
Mts 3- Heating  Oil
Mts 3- Cutting Vegetables
Mts 4- Cutting Vegetables
Mts 4- Heating  Oil
Mts 5- Heating  Oil
Mts 5- Cutting Vegetables
Mts 6- Heating  Oil
Mts 6- Cutting Vegetables
CUTTING VEG. IS OVER
HEATING OIL IS OVER
Main Program COOKING proceeds...

Click to see Thread creation by extendeding Thread class
                                 

Thursday, February 18, 2016

Java - Date Formatting (USA,UK and ISO 8601 format) and simple Array handling


Dates are classified as Big-endian, Little-endian and Middle-endian.
Big-Endian meaning Most significant to Least significant, ie Year->Month->Day
Little-Endian meaning Least significant to Most significant, ie  Day->Month->Year
Middle-Endian means it is neither of the above, ie it is Month->Day->Year.

We can see
International Standard ISO 8601 notation follows Big-Endian format (YYYY/MM/DD)
British date notation follows Little-Endian format.(DD/MM/YY)
American date notation follows Middle-Endian format.(MM/DD/YY).

Among the above formats (using only numbers).
USA and UK notations can cause confusion, but not ISO 8601 format.
For instance
The date 02/03/16 can indicate two different dates.
UK notation (Little-Endian) means, it is 2nd of March in the year 2016.
USA notation (Middle-Endian) means, it is 3rd of February in the Year 2016.

But using numbers has advantages.
It is language independent, easy to read, enter and manipulate.
International Standard ISO 8601 notation is most suitable for this purpose.
Its noattion being YYYY-MM-DD.
It can't be misread even if we remove the separators(YYYYMMDD).

Having said that,
there are other factors which would decide the final format.

This simple program uses an array to store the above date formats and
displays the system date in each format through a 'for' loop with description.



/* RESOURCES required

import java.util.Date; // For date object with current date and time
import java.text.SimpleDateFormat; // to apply user format

public class GetDateTime {

    public static void main(String[] args) {
     
        /* Arrays to store date formats and their description
       Note: Formats are case sensitive- (Eg)'M' for month, 'm' for minutes */
     
        String[] DateFts   = { "YYYY/MM/dd",
                                           "MM.dd.yy",
                                           "dd/MM/yy"};   
        String[] DateFtsDes = { "ISO 8601 notation (Big",
                             " USA notation (Middle",
                             " UK notation (Little"};
   
        // date object 'dateobj' with current date 

       Date dateobj = new Date();

       //'df' as SimpleDateformat object

       SimpleDateFormat df;
       int i;

       // Displaying date  without formatting

       System.out.println( "Unformatted Current date with time: " + dateobj);
       System.out.println( "Formated date with SimpleDateFormat(): ");
   
       // loop to display date in the formats stored in the Array

         for (i=0;i<DateFts.length;++i){  
       df = new SimpleDateFormat(DateFts[i]); //Initializing 'df' through iteration 
       System.out.println( (i+1) + ") "                 // Array Index starts with 0,so i+1 
                                 +" Format      : "  + "SimpleDateFormat("
                                 + DateFts[i] + ")"           // To display Format text
                                 + "\n" + "    Output      : "
                                 + df.format(dateobj) + "      " //Formating the Date
                                 +"\n" +"    Description :"
                                 + DateFtsDes[i]                   // To display description 
                                 + "-Endian)");
         
       }
    }
}

Output of the Program:

Unformatted Current date with time: Thu Feb 18 16:08:22 IST 2016
Formated date with SimpleDateFormat():
1)  Format      : SimpleDateFormat(YYYY/MM/dd)
    Output      : 2016/02/18    
    Description :ISO 8601 notation (Big-Endian)
2)  Format      : SimpleDateFormat(MM.dd.yy)
    Output      : 02.18.16    
    Description : USA notation (Middle-Endian)
3)  Format      : SimpleDateFormat(dd/MM/yy)
    Output      : 18/02/16    
    Description : UK notation (Little-Endian)
     
 
 

Saturday, February 13, 2016

Java - DBMS - Row/Record locking through a table column


In a multiuser environment same row/record may be accessed/updated concurrently
This could cause data inconsistency and anomaly.
Locking as such is a wide concept and can be implemented in many ways.
It differs according to the DBMS, language and complexity of the project.
by more than one user.

To avoid such situations and maintain data integrity, locking concept is applied.
In this example program,
record locking is done by having a separate column for LOCK status in the table. 
This is done through program logic.
A row is retrieved for UPDATE, only if the LOCK column is marked as FALSE.
If LOCK status is FALSE, the program marks the LOCK status TRUE, writes it to 
the database and allows the user to make changes.
After the user update, it writes the UPDATED row and changes LOCK 
status to FALSE again.
So that it can be accessed by other users.

Software used is  NetBeans IDE 8.0.2. 
Note : ClientId is unique and do not allow duplicates.
Database is created in JavaDB which is part of JDK package.Database ClientDB and table Mailist and records are created through the wizard.Programs also created using Netbeans IDE 8.0.2.Same code holds good for other DBMS with the corresponding driver program.



Database Name : ClientDB
Table Name        :       Maillist
Table Attributes  :         ClientId             N   
                                        ClientName  A/N  
                                        ClientEmail  A/N  
                                        Lock             Boolean
EXAMPLE -

package lockbycolumn;
import java.sql.Connection;
import java.sql.DriverManager; 
import java.sql.Statement; 
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException; 
import java.util.Scanner; 

public class LockByColumn {
String host = "jdbc:derby://localhost:1527/clientDB";
String UserName = "parthiban";
String UserPassword = "password";
String sql; 
Connection con;
ResultSet rs;
PreparedStatement ps;
Statement ss;
Scanner AcceptInput = new Scanner(System.in);
int WClientId; // Work Variables
String WClientName, WClientEmail,Wlock; 

  
    public static void main(String[] args) {
        // Cmo is created to enable non static method calling from static Main
       LockByColumn Cmo = new LockByColumn();
        Scanner AcceptInput = new Scanner(System.in);
        String OptionInput;
        Cmo.ConnectMethod();
         do { 
        System.out.println( " ** Select an Operation **");
        System.out.println( " Retrieval of Record - 1");
        System.out.println( " Update of Record    - 2");
        System.out.println( " Exit                - 0");
        System.out.println( " ENTER OPTION - ");
        OptionInput = AcceptInput.next();
    
        switch (OptionInput) {
          
            case "1":
                Cmo.RetrieveRecord();
                break;
            case "2":                
                Cmo.UpdateRecord();
                break;
            case "0":
         // For input 0, program is terminated
                 System.out.println("Ending Session");
                System.exit(0);
                break;
            default:
                System.out.println("Invalid selection - Reenter");
                break; 
         } // end switch
        // Note, how string value is checked for not = "0"
        }  while (!OptionInput.equals("0"));    
    }// end main
    
       /* CONNECTION METHOD */
     public void ConnectMethod(){
         try{
         con = DriverManager.getConnection(host,UserName,UserPassword);                     
            System.out.println(" Connected..");
            }
        catch (SQLException err){
            System.out.println("ERROR:"+err.getMessage());
        }
    }

        /* RECORD RETIEVAL METHOD */

/* this method lists rows with UNDER UPDATE message if that row is under
process by another user */

        public void RetrieveRecord(){
        System.out.println("RECORD RETRIEVAL");
        WClientId =1;
             try {
                        
             sql ="SELECT * from MAILLIST "; 
              ps = con.prepareStatement(sql);
              rs=ps.executeQuery();
              while(rs.next()){
               WClientId = rs.getInt(1);
               WClientName = rs.getString(2);
               WClientEmail = rs.getString(3);
               Wlock="     ";
               /* If LOCK column is TRUE,then Uner Update message is displayed */
               if (rs.getBoolean(4)){
                   Wlock = " -- Under UPDATE --";
               }
            
               System.out.println("Client Id : " + WClientId + ", Name : "
                       + WClientName + ",  EMail : " + WClientEmail 
                        + Wlock);
            
               }
           
        }
        catch (SQLException err){
            System.out.println("ERROR:"+err.getMessage());
        }
    }
      
      /* RECORD UPDATE METHOD */
    
    public void UpdateRecord(){
       System.out.println("RECORD UPDATE");
        WClientId = 1;
       try {
             while (WClientId != 0) {
           System.out.println("Enter Client Id (0 to EXIT): ");
              WClientId = AcceptInput.nextInt();
               AcceptInput.nextLine();// to avoid skipping next input
               
               if (WClientId !=0){
             sql ="SELECT Clientname,clientemail,lock from  MAILLIST where CLIENTID = ? "; 
              ps = con.prepareStatement(sql);
              ps.setInt(1, WClientId);
              rs=ps.executeQuery();
              rs.next(); 
               WClientName = rs.getString(1);
               WClientEmail = rs.getString(2);
               Wlock ="";
               /* if LOCK column is TRUE display RECORD is locked message */
               if (rs.getBoolean(3)){
                    System.out.println( "Record is Locked");
                                             
             }
               /* If RECORD is not locked, update LOCK column as TRUE
                  and proceed with update */ 
               else {
                    sql ="UPDATE MAILLIST set lock = ?  where ClientId = ? ";
            ps = con.prepareStatement(sql);
            ps.setInt(2, WClientId);
            ps.setBoolean(1,true);
            ps.executeUpdate();
            System.out.println("Client Id : " + WClientId + ", Name : "
                       + WClientName + ", Current EMail : " + WClientEmail);
               System.out.println("Enter New Email or press ENTER for no chnage):");
               WClientEmail = AcceptInput.nextLine();// New Email
               sql ="UPDATE MAILLIST SET ClientEmail = ? ,lock = ? where ClientId = ? ";
            ps = con.prepareStatement(sql);
             ps.setString(1,WClientEmail);
             /* Reset LOCK column as FALSE as part of update */
             ps.setBoolean(2,false );
            ps.setInt(3, WClientId);
            ps.executeUpdate();
         
               } 
                   } 
                }
        } 
        catch (SQLException err){
            System.out.println("ERROR:"+err.getMessage());
        } 

    }
}