Вы находитесь на странице: 1из 3

Java is a 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 code that runs on one platform does not need to be recompiled to run on another. Java applications are typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM) regardless of computer architecture. Java is, as of 2012, one of the most popular programming languages in use, [10][11] 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 merged into 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 developed by Sun from 1991 and first released in 1995. As of May 2007, in compliance with the specifications of the Java Community Process, Sun relicensed most of its Java technologies under theGNU 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).

Java programs: Java programming code consists of instructions which will be executed on your computer system to perform a task as an example say arrange given integers in ascending order. This page contains examples for beginners to understand how to use java programming for beginners to write simple Java programs. These codes demonstrate how to get input from user, working with loops, strings and arrays. Programs are provided with output (image file) and you can also download class file and execute it directly without compiling the source file.

Compiling and executing java programs


Java programming software: To compile and run Java program code you need to download JDK (Java Development Kit). To compile type: javac file_name.java where file_name is name of file containing java source code. Javac is the Java compiler which converts java code into bytecode. To run type: java main_method_class where main_method_class is the name of class which defines main method.

Program to Bubble Sort

import java.util.Scanner; class BubbleSort { public static void main(String []args) { int n, c, d, swap; Scanner in = new Scanner(System.in); System.out.println("Input number of integers to sort"); n = in.nextInt(); int array[] = new int[n]; System.out.println("Enter " + n + " integers"); for (c = 0; c < n; c++) array[c] = in.nextInt(); for (c = 0; c < ( n - 1 ); c++) { for (d = 0; d < n - c - 1; d++) { if (array[d] > array[d+1]) /* For descending order use < */ { swap = array[d]; array[d] = array[d+1]; array[d+1] = swap; } } } System.out.println("Sorted list of numbers"); for (c = 0; c < n; c++) System.out.println(array[c]); } }

Вам также может понравиться