Showing posts with label java programs. Show all posts
Showing posts with label java programs. Show all posts

Thursday, January 11, 2018

function to print the repeated values in an array with it's count

public static void printRepeating(int arr[], int size)
{
int i,j;
System.out.println("The repeating elements are : ");
HashMap<Integer, Integer> hmap = new HashMap<>();

for (i = 0; i < size-1; i++)
{
int c=1;
for (j = i+1; j < size; j++)
{

if(arr[i]==arr[j]){
c++;
}
}
if(c>1&& !hmap.containsValue(arr[i])){

hmap.put(c,arr[i]);

}
}

for (int k:hmap.keySet()){
System.out.println(hmap.get(k)+" : count "+k);
}
}


Sunday, January 7, 2018

java program to download file from url


import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public class URLReader {

    public static void copyURLToFile(URL url, File file) {

        try {
            InputStream input = url.openStream();
            if (file.exists()) {
                if (file.isDirectory())
                    throw new IOException("File '" + file + "' is a directory");

                if (!file.canWrite())
                    throw new IOException("File '" + file + "' cannot be written");
            } else {
                File parent = file.getParentFile();
                if ((parent != null) && (!parent.exists()) && (!parent.mkdirs())) {
                    throw new IOException("File '" + file + "' could not be created");
                }
            }

            FileOutputStream output = new FileOutputStream(file);

            byte[] buffer = new byte[4096];
            int n = 0;
            while (-1 != (n = input.read(buffer))) {
                output.write(buffer, 0, n);
            }

            input.close();
            output.close();

            System.out.println("File '" + file + "' downloaded successfully!");
        }
        catch(IOException ioEx) {
            ioEx.printStackTrace();
        }
    }

    public static void main(String[] args) throws IOException {

        //URL pointing to the file
        String sUrl = "https://singztechmusings.files.wordpress.com/2011/09/maven_eclipse_and_osgi_working_together.pdf";

        URL url = new URL(sUrl);

        //File where to be downloaded
        File file = new File("home\\sujith\\IdeaProjects\\downloadTest");

        URLReader.copyURLToFile(url, file);
    }

}

java program to download a file from an external url

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.commons.io.FileUtils;
public class FileDownloadTest {
public static void main(String[] args) {
try {
// Make sure that this directory exists
String dirName = "home\\sujith\\FileDownload";
System.out.println("Downloading \'Maven, Eclipse and OSGi working together\' PDF document...");
saveFileFromUrlWithJavaIO(
dirName + "\\maven_eclipse_and_osgi_working_together.pdf",
"https://singztechmusings.files.wordpress.com/2011/09/maven_eclipse_and_osgi_working_together.pdf");
System.out.println("Downloaded \'Maven, Eclipse and OSGi working together\' PDF document.");
System.out.println("Downloading \'InnoQ Web Services Standards Poster\' PDF document...");
saveFileFromUrlWithCommonsIO(
dirName + "\\innoq_ws-standards_poster_2007-02.pdf",
"http://singztechmusings.files.wordpress.com/2011/08/innoq_ws-standards_poster_2007-02.pdf");
System.out.println("Downloaded \'InnoQ Web Services Standards Poster\' PDF document.");
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
// Using Java IO
public static void saveFileFromUrlWithJavaIO(String fileName, String fileUrl)
throws MalformedURLException, IOException {
BufferedInputStream in = null;
FileOutputStream fout = null;
try {
in = new BufferedInputStream(new URL(fileUrl).openStream());
fout = new FileOutputStream(fileName);
byte data[] = new byte[1024];
int count;
while ((count = in.read(data, 0, 1024)) != -1) {
fout.write(data, 0, count);
}
} finally {
if (in != null)
in.close();
if (fout != null)
fout.close();
}
}
// Using Commons IO library
// Available at http://commons.apache.org/io/download_io.cgi
public static void saveFileFromUrlWithCommonsIO(String fileName,
String fileUrl) throws MalformedURLException, IOException {
FileUtils.copyURLToFile(new URL(fileUrl), new File(fileName));
}
}

//https://mvnrepository.com/artifact/commons-io/commons-io/2.4

Tuesday, February 7, 2017

Java Program to Generate the all Non repeated sequence of the Array values


package p1;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
/**
 *
 * @author sujith
 */
class ticketGenerator {

    static void ticketGenerator(int arr[], int n, int r, int index,
                                int data[], int i,ArrayList ar)
    {
       
        if (index == r)
        {
            int arr1[]= new int[r];
            String st="";
            for (int j=0; j<r; j++){
                arr1[j]=data[j];
                st=st+data[j]+" ";
            }
            pHelper(arr1,0,ar);
            ar.add(st);
        return;
        }
        if (i >= n)
            return;
        data[index] = arr[i];
        ticketGenerator(arr, n, r, index+1, data, i+1,ar);
        ticketGenerator(arr, n, r, index, data, i+1,ar);
    }

    static void printTicket(int arr[], int n, int r,ArrayList ar)
    {
        int data[]=new int[r];
        ticketGenerator(arr, n, r, 0, data, 0,ar);
    }
   
   
private static void pHelper(int[] arr, int index,ArrayList mylist){
    if(index >= arr.length - 1){
        String st="";
        for(int i = 0; i < arr.length - 1; i++){
            st=st+arr[i]+" ";
        }
        if(arr.length > 0) {
            st=st+arr[arr.length - 1];
        }
        mylist.add(st);
        return;
    }

    for(int i = index; i < arr.length; i++){
        int t = arr[index];
        arr[index] = arr[i];
        arr[i] = t;
        pHelper(arr, index+1,mylist);
        t = arr[index];
        arr[index] = arr[i];
        arr[i] = t;
    }
}
    public static void main (String[] args) {
        Scanner sc=new Scanner(System.in);
        ArrayList<String> ar= new ArrayList<>();
        System.out.println("Enter the number of Tickets");
        int n=sc.nextInt();
        int arr[]= new int[n];
        System.out.println("Enter the Tickets");
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
        }
        System.out.println("Enter the  generation sequence limit");
        int r =sc.nextInt();
        printTicket(arr, n, r,ar);
        Collections.shuffle(ar);
        System.out.println("The generated Keys");
        for (String temp : ar) {
            System.out.println(temp);
        }
    }
}

Thursday, August 18, 2016

csv file processing in java


 */
/**/package excel
import java.io.*;
import java.util.StringTokenizer;

public class Cl1 {

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub

String name;
String roll;
int marks;

File f = new File("C:\\Users\\user\\Documents\\cvv2.csv"); // file path, please change as per your requirements
int ss = size(f);
System.out.println(ss);
String sen[][] = new String [ss][2];
//get the classes ready for file reading

FileInputStream fis = new FileInputStream(f);
InputStreamReader isr = new  InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);

//-------------------------------------------

String line="";
int index=0;

while((line=br.readLine())!=null){ //read each line
StringTokenizer t = new StringTokenizer(line,","); // split the words
while(t.hasMoreTokens()){
sen[index][0] = t.nextToken();  // store first  word in the zeroth position of the matrix
sen[index++][1] = t.nextToken();// store second word in the first position of the matrix


}

}
//close all the necessary file objects.
fis.close();
   isr.close();
   br.close();
   //modify
   FileWriter fr = new FileWriter(f); // open file writer
   System.out.println("Increment roll numbers by  and store again: ");
   fr.write("Name,Roll\n"); // write the header
   int j=1;
   while(j<ss){
    //sen
    sen[j][1] = Integer.toString(Integer.parseInt(sen[j][1])+5);
    fr.write(sen[j][0]+","+sen[j++][1]+"\n");
   }
   fr.close();
   read(f);
   //modify
 
 
}
static void read(File f) throws IOException{ // function to display file content
FileInputStream fis = new FileInputStream(f);
InputStreamReader isr = new  InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String line;
while((line = br.readLine())!=null){
System.out.println(line);
}
fis.close();
br.close();
isr.close();

}
static int size(File ff){// function to get the total lines in the file including the header
File f = ff;
int si = 0;
FileInputStream fis;
try {
System.out.println(f);
fis = new FileInputStream(f);
InputStreamReader isr = new  InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String line="";

while((br.readLine())!=null){
si++;
}

fis.close();
   isr.close();
   br.close();
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("gggg");
e.printStackTrace();
}

return si;
}

}

arraylist with iterator in java


package p1;
import java.io.File;
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author sujith
 */
public class fileprgm {
 
    public static void main(String[] args) {
        File f1 = new File("e:\\data6.csv");
        try {
            BufferedReader br= new BufferedReader(new InputStreamReader(new FileInputStream(f1)));
            String line;
            List<String> ar = new ArrayList<String>();
            while((line=br.readLine())!=null){
                StringTokenizer st= new StringTokenizer(line,",");
                while(st.hasMoreTokens()){
             
                 
                    ar.add(st.nextToken());
                         
                }
             
            }
         

            Iterator<String> crunchifyIterator = ar.iterator();
while (crunchifyIterator.hasNext()) {

                        if(crunchifyIterator.hasNext()){
                           System.out.print(crunchifyIterator.next()+" ");
                        }
                        if(crunchifyIterator.hasNext()){
                           System.out.print(crunchifyIterator.next()+" ");
                        }
                        if(crunchifyIterator.hasNext()){
                           System.out.print(crunchifyIterator.next()+" ");
                        }

                        System.out.print("\n");
}
        } catch (Exception ex) {
            Logger.getLogger(msuppu.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
}

file prgm csv,txt handling

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package p1;
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;


public class add_csv {
    public static void main(String[] args) {
        File f1= new File("E://data4.txt");
         BufferedReader br,br2;
         int size=0;
        try {
            br = new BufferedReader(new FileReader(f1));
              String line;
              int sum=0;
            while((line=br.readLine())!=null){
                StringTokenizer st= new StringTokenizer(line,",");
                while(st.hasMoreTokens()){
                    String p=st.nextToken();
                    //sum+=Integer.parseInt(p);
                    System.out.println(p);
                    size++;
                }
   
            }
            br.close();
            br2 = new BufferedReader(new FileReader("E://data4.txt"));
            FileOutputStream os= new FileOutputStream("E://copy4.txt");
            String[] myst= new String[size];
            int i=0;
            while((line=br2.readLine())!=null){
                 StringTokenizer st= new StringTokenizer(line,",");
                  while(st.hasMoreTokens()){
                    String p=st.nextToken();
                    myst[i++]=p;
                      //System.out.println(i);
                }
            }
            System.out.println(" ");
            for(int k=0;k<size;k++){
                for(int j=k+1;j<size;j++){
                    if(myst[k].compareTo(myst[j])>0){
                    String temp=myst[k];
                       // System.out.println("hi");
                    myst[k]=myst[j];
                    myst[j]=temp;
                    }
                }
            }
            for(String pintu:myst){
              System.out.println(pintu);  
              os.write(pintu.getBytes());
              os.write(" \n".getBytes());
            }
            System.out.println("The sum of integer is "+sum);  
        } catch (Exception ex) {
            Logger.getLogger(add_csv.class.getName()).log(Level.SEVERE, null, ex);
        }
         
    }
}

rough work 1 file read and write

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package p1;

import java.io.BufferedReader;
import java.io.File;
import java.io.*;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.*;

/**
 *
 * @author sujith
 */
public class str3 {
    public static void main(String[] args){
        File file= new File("C:\\data3.txt");
        File file2=new File("C:\\data3.txt");
       // String[] tokens = null;
        int k=0;
        try{
        //BufferedReader br= new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            // BufferedReader br= new BufferedReader(new FileReader(f));
            BufferedReader br= new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            FileInputStream in= new FileInputStream("C:\\data3.txt");
            FileOutputStream op= new FileOutputStream("E:\\data5.txt");
            //InputStreamReader ip=new InputStreamReader(in);          
            //OutputStreamWriter op= new OutputStreamWriter(new FileOutputStream("E:\\data4.txt"));
            //BufferedReader br= new BufferedReader(in);
           // System.out.println(ip);
            while((k=in.read())!=-1){
                System.out.println((char)k);
               // op.write(k);
               // op.append((char)k);
               // System.out.println((byte)k);
              
            }
        String line=null;
        int count=0;
        int i=0;
       
        while((line=br.readLine())!=null){
            //tokens=line.split("\\s+");
            StringTokenizer st= new StringTokenizer(line," ");
          
           while(st.hasMoreTokens()){
               String s=st.nextToken();
               char c;
               StringBuffer sb=new StringBuffer(s);
              for(int j=0;j<sb.length();j++){
                  for(int m=j+1;m<sb.length();m++){
                     // System.out.println(sb.ch);
                      //sb.setCharAt(i, ch);
                      if(sb.charAt(j)>sb.charAt(m)){
                          c=sb.charAt(j);
                          sb.setCharAt(j,sb.charAt(m));
                          sb.setCharAt(m, c);
                      }
                    
                  }
              }
              System.out.println(sb);
               //System.out.println(st.nextToken());             
               //StringBuffer sb=new StringBuffer(st.nextToken());
               // StringBuilder sb= new StringBuilder(st.nextToken());
               //String sb=st.nextToken();
              // String[] sb=new String[]{st.nextToken()};
               //System.out.println(sb.length);
              // System.out.println(st.nextToken());
              
              // op.write(st.nextToken().getBytes());
              // op.write(" ".getBytes());
              
               //System.out.println(st.nextToken().getClass().getName());
             
               op.write(sb.toString().getBytes());
               op.write(" ".getBytes());
           }
            op.write("\n".getBytes());
          
        }
       

        }catch(Exception e){
            System.out.println(e);
        }
    }
   
}

Saturday, November 16, 2013

java Program to Implement Thread using Runnable Interface

Program to Implement Thread using Runnable Interface
class A implements Runnable
{
public void run()
{
for(int i=0; i<20; i++)
{
System.out.println(i);
}
}
}
class Run1
{
public static void main(String args[])
{
A a1 = new A();
Thread t = new Thread(a1);
t.start();
}
}

java program to Implement this and super Keyword

Program to Implement this and super Keyword
class vehicle
{
int id;
String color;
vehicle(int regno,String color)
{
id = regno;
this.color = color;
}
}
class vchl extends vehicle
{
int id;
String color;
vchl(int i1,int i2,String s1,String s2)
{
super(i2,s2);
id = i1;
color = s1;
}
void pdata()
{
System.out.print(super.id);
}
void ddata()
{
System.out.print(super.color);
}
public static void main(String arg[])
{
vchl v = new vchl(10,2334,"GREY","WHITE");
System.out.print("Vehicle color is ");
v.ddata();
System.out.print("\nVehicle number is ");
v.pdata();
System.out.println("\nVehicle engine color is "
+ v.color);
System.out.println("Vehicle engine id is " + v.id);
}
}
class single_inherit
{
public static void main(String a[])
{
radha m = new radha();
m.get(520,22000);
m.show1();
}
}

Wednesday, September 18, 2013

java Program to Implement the Concept of Inheritance

 Program to Implement the Concept of Inheritance
class prnt
{
int a, s;
void show()
{
System.out.println("Fathre name: Mr. Roshan Lal");
}
}
class radha extends prnt
{
void get(int x,int y)
{
a = x;
s = y;
}
void show1()
{
show();
System.out.println("Std name: Radha");
System.out.println("age:" + a);
System.out.println("salary:" + s);
}
}

class single_inherit
{
public static void main(String a[])
{
radha m = new radha();
m.get(520,22000);
m.show1();
}
}

Program to Implement the Basic Functionality of a Calculator using Switch

Program to Implement the Basic Functionality of a Calculator
using Switch
import java.io.DataInputStream;
class Cal
{
public static void main(String args[])
{
DataInputStream pt=new DataInputStream(System.in);
int x,y,z,ch;
try
{
System.out.println("Enter Value of X:");
x = Integer.parseInt(pt.readLine());
System.out.println("Enter Value of Y:");
y = Integer.parseInt(pt.readLine());
System.out.println("1.Addition\n2.Subtraction
\n3.Multiplication\n4.Division");
System.out.println("Enter ur choice:");
ch = Integer.parseInt(pt.readLine());
switch(ch)
{
case 1:
z = x + y;
System.out.println("The Addition is:"+z);
break;
case 2:
z = x - y;
System.out.println("The Subtraction
is:"+z);
break;

case 3:
z = x * y;
System.out.println("The Multiplication
is:"+z);
break;
case 4:
z = x / y;
System.out.println("The Division is:"+z);
break;
default:
System.out.println("Sorry Try
Again.........");
break;
}
}
catch(Exception e)
{
System.out.println("x.getmessage()");
}
}
}

Program to Implement Overriding of Methods

 Program to Implement Overriding of Methods
class bca
{
int d;
void get(int x)
{
d = x;
}
void display()
{
System.out.println("Bca = " + d);
}
}
class mca extends bca
{
int y;
mca(int m, int y)
{
get(m);
this.y = y;
}
void display()
{
System.out.println("Bca = " + d);
System.out.println("mca y= " + y);
}
}

class override
{
public static void main(String a[])
{
mca m = new mca(100,200);
m.display();
}
}

Friday, August 16, 2013

java Program to Implement Overloading of Methods

 Program to Implement Overloading of Methods
class prnt
{
int a, a1, s, s1;
void show()
{
System.out.println("Father name: Mr.Roshan lal");
System.out.println("Mother Name: Mrs. Madhu Gupta") ;
}
}
class radha extends prnt
{
void get(int y)
{
a = 19;
s = y;
}
void show1()
{
System.out.println("\nstd name:Radha Garg");
System.out.println("age:" + a);
System.out.println("salary:" + s);
}
}
class money extends radha
{
void get(int x1,int y1)
{
a1 = x1;
s1 = y1;
}

void show2()
{
System.out.println("\nstd name:Money Garg");
System.out.println("age:" + a1);
System.out.println("salary:" + s1);
}
void shows()
{
show();
show1();
show2();
}
}
class overloading
{
public static void main(String z[])
{
money m = new money();
m.get(20,30000);
m.get(25000);
m.shows();
}
}

java Program to Implement Multithreading

Program to Implement Multithreading
import java.lang.*;
class aa extends Thread
{
public void run()
{
for(int i=0;i<4;i++)
{
try
{
if(i == 3)
{
sleep(4000);
}
}
catch(Exception x)
{ }
System.out.println(i);
}
System.out.println(" i finished ");
}
}
class bb extends Thread
{
public void run()
{
for(int i=0; i<4; i++)
{
System.out.println(i);
}
System.out.println(" ii finished ");
}
}

class cc extends Thread
{
public void run()
{
for(int i=0; i<4; i++)
{
System.out.println(i);
}
System.out.println(" iii finished ");
}
}
class multi_thread
{
public static void main(String arg[])
{
aa a1 = new aa();
bb b1 = new bb();
cc c1 = new cc();
a1.start();
b1.start();
c1.start();
}
}

java Program to Illustrate the use of Methods of Vector Class

 Program to Illustrate the use of Methods of Vector Class
import java.util.*;
class vctr
{
public static void main(String arg[])
{
Vector list = new Vector();
int l = arg.length;
for(int i=0; i<l; i++)
{
list.addElement(arg[i]);
}
list.insertElementAt("COBOL",2);
int size = list.size();
String lary[ ] = new String[size];
list.copyInto(lary);
System.out.println("List of Languages");
for(int i=0; i<size; i++)
{
System.out.println(lary[i]);
}
}
}

java Program to Illustrate the use of Methods of String Class

Program to Illustrate the use of Methods of String Class
import java.io.*;
class String1
{
public static void main(String arg[])
{
try
{
int n = 5;
int m = 8;
char s = 'n';
String str = new String(" Radha");
String str3 = new String(" Radha ");
String str4;
System.out.println(str.equals(str3));
String str1 = str.toLowerCase();
System.out.println("The String in Lower case:"
+ str1);
String str2 = str1.toUpperCase();
System.out.println("The String in Upper case:"
+ str2);
str4 = str1.trim();
System.out.println("The String after trimming:"
+ str4);
System.out.println("The length of String:"
+ str4.length());
str2 = str1.replace('h','d');
System.out.println("The repalced String" + str2);
System.out.println(str1.equals(str2));
System.out.println("The character at position 3:"
+ str2.charAt(3));System.out.println("The substring is:"
+ str2.substring(n));
System.out.println("The substring is:"+ str2.substring(n,m));
System.out.println("The Index of O:"+ str2.indexOf(s));
}
catch(Exception s)
{
System.out.println(s.getMessage());
}
}
}

Wednesday, August 7, 2013

java Program to Illustrate the use of Methods of StringBuffer Class

 Program to Illustrate the use of Methods of StringBuffer Class

import java.io.*;
import java.lang.*;
class Stringb
{
public static void main(String args[])
{
try
{
StringBuffer str=new StringBuffer("Radha Garg");
System.out.println("\n1.Length\n2.Capacity
\n3.Setlength\n4.Charat\n5.Setcharat
\n6.Append\n7.Deletecharat\n8.Substring
\n9.Substring1\n10.Insert\n11.Reverse");
System.out.println("Enter ur chioce");
DataInputStream ds = new DataInputStream(System.in);
int ch = Integer.parseInt(ds.readLine());
switch(ch)
{
case 1:
System.out.println("The length of the
string is:" + str.length());
break;
case 2:
System.out.println("The capacity of
String:" + str.capacity());
break;
case 3:
str.setLength(15);
System.out.println("Set length of String:"
+ str.length());
break;
case 4:
System.out.println("The character at 6th
position:" + str.charAt(5));
break;
case 5:
str.setCharAt(2,'u');
System.out.println("The string after
setting position is:" +str);
break;
case 6:
System.out.println("The string after
appending:" + str.append(" Sohni"));
break;
case 7:
System.out.println("The string after
deletion:" + str.deleteCharAt(7));
break;
case 8:
System.out.println("The substring is:" +
str.substring(2));
break;
case 9:
System.out.println("The subsstring2 is:" +
str.substring(3,8));
break;
case 10:
System.out.println(" The string after
insertion is:" + str.insert(6,'m'));
break;
case 11:
System.out.println("The string after
reverse is:" + str.reverse());
}
}
catch(Exception s)
{
System.out.println(s.getMessage());
}
}
}
Output:

JAVA Program to Handle In-built Exceptions

Program to Handle any Three In-built Exceptions
class checkExcept
{
public void add()
{
try
{
int y = 20,z = 0;
int x = y/z;
System.out.println(x);
System.out.println("working");
}
catch(ArithmeticException a)
{
System.out.println("error");
}
catch(SecurityException a2)
{
System.out.println("error");
}
catch(ArrayStoreException a1)
{ }
catch(Exception x)
{
System.out.println(x.getMessage());
}
finally
{
System.out.println("finaly");
}
}

public static void main(String a[])
{
checkExcept c = new checkExcept();
c.add();
}
}


Monday, July 29, 2013

Java Program to Find the Sum of the Digits of a Number

Program to Find the Sum of the Digits of a Number
import java.io.*;
class Add
{
void number()
{
try
{
int num,sum=0;
System.out.println("Enter any number:");
DataInputStream dts=new DataInputStream(System.in);
int n=Integer.parseInt(dts.readLine());
while ( n > 0 )
{
num = n % 10;
n = n / 10;
sum = sum + num;
}
System.out.println("The sum of the digits is:"
+sum);
}
catch(Exception s)
{
System.out.println(s.getMessage());
}
}
}

class Digit_add
{
public static void main(String args[])
{
Add a = new Add();
a.number();
}
}