JAVA



Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. As of 2015, Java is one of the most popular programming languages in use, particularly for client-server web applications, with a reported 9 million developers. Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them.
The original and reference implementation Java compilers, virtual machines, and class libraries were originally released by Sun under proprietary licences. As of May 2007, in compliance with the specifications of the Java Community Process, Sun relicensed most of its Java technologies under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java (bytecode compiler), GNU Classpath (standard libraries), and IcedTea-Web (browser plugin for applets).
The latest version is Java 8, which is the only version currently supported for free by Oracle, although earlier versions are supported both by Oracle and other companies on a commercial basis.
Source  

simple java program ..array :


package ov;

import java.util.Scanner;
class Arry{
    public static void main(String args[])
    {
        int i, a[],n,m, b[];
        int d[ ];
        Scanner in =new Scanner (System.in);
        System.out.println("The array size is : ");
        n=in.nextInt();
        System.out.println("Input array elements: ");
        a= new int[n];
        for(i=0; i<n; i++)
        {
            a[i]= in.nextInt();
        }
        System.out.println("The array is : ");
        for(i=0; i<n; i++)
                {
                    System.out.print(" " +a[i]);
        }
        System.out.println("\nThe array size is : ");
                m=in.nextInt();
                System.out.println("Input array elements: ");
                b= new int[m];
                for(i=0; i<m; i++)
                {
                    b[i]= in.nextInt();
                }
                System.out.println("The array is : ");
                for(i=0; i<n; i++)
                        {
                            System.out.print(" "+b[i]);
                            d[i] = a[i]+ b[i];
        }

                for(i=0; i<n; i++)
                                {
                                System.out.print(" " +d[i]);
                }

    }

}

simple java program thread  file : 
package Seventhlecture;

public class OurThread extends Thread {
   
    //.........Variable.............
   
    private String threadName;
    private int startingPoint;
    private int counter;
    private int adder;
    private int timeDifference;
   
    private boolean threadAliveFlag;
   
   
   
    //...................Constructor.. ...............
   
    public OurThread(String threadName, int startingPoint,
            int adder, int timeDifference, boolean threadAliveFlag) {
        super();
        this.threadName = threadName;
        this.startingPoint = startingPoint;
        this.adder = adder;
        this.timeDifference = timeDifference;
        this.threadAliveFlag = threadAliveFlag;
    }
   
    //................. run() method.............
   
    @Override
    public void run(){
        counter=startingPoint;
        while (threadAliveFlag){
        counter+=adder;
        try{
        sleep(timeDifference);
      
        }
        catch(InterruptedException e){
            e.printStackTrace();
        }
        }
    }
   
    public void stopThread(){
        threadAliveFlag=false;
    }
   
   
   
    // ..........getter and setter method .............
   
   
    public String getThreadName() {
        return threadName;
    }


    public void setThreadName(String threadName) {
        this.threadName = threadName;
    }


    public int getStartingPoint() {
        return startingPoint;
    }


    public void setStartingPoint(int startingPoint) {
        this.startingPoint = startingPoint;
    }


    public int getCounter() {
        return counter;
    }


    public void setCounter(int counter) {
        this.counter = counter;
    }


    public int getAdder() {
        return adder;
    }


    public void setAdder(int adder) {
        this.adder = adder;
    }


    public int getTimeDifference() {
        return timeDifference;
    }


    public void setTimeDifference(int timeDifference) {
        this.timeDifference = timeDifference;
    }


    public boolean isThreadAliveFlag() {
        return threadAliveFlag;
    }


    public void setThreadAliveFlag(boolean threadAliveFlag) {
        this.threadAliveFlag = threadAliveFlag;
    }


   
   

   

}
 

No comments:

Post a Comment