GNU Free Documentation License . .

Java

: ,
Java
Java logo.png
:

-, , ,

:

1995

():

Oracle Corporation ( Sun Microsystems)

:

Java Standard Edition 7[1] (28 2011)

:

, , ,  (.),  (.)

:

 (.)

:

Generic Java (.), Pizza (.)

:

Objective-C[2], 83, Object Pascal[3], UCSD Pascal[4], Oberon[5][6],C++, C#[7], Smalltalk, Eiffel[8], Mesa (.)[9], Modula-3[10], Generic Java (.)

:

2005, C#, Clojure, D, ECMAScript, Groovy, J#, VJ#, JavaScript, PHP, Scala, Python, BeanShell

GNU General Public License / Java Community Process

:

http://oracle.com/technetwork/java/

Java  - , Sun Microsystems ( Oracle). Java -, Java- (JVM) .   23 1995 .

[]

: «» «»[11]. Java ,   «» «», . «» ( «») [12]. «» (, (Java Users Group)[13].

, .

«» (Oak) . «» . «» ( , ), . , -, , .

[]

Java -, Java (JVM)  , .

, Java

  - , Java- , . Java , . , (, ) .

, - , Java. , Java:

shootout.alioth.debian.org, Java - , C/C++, Java , 7 .[14] , Java- 10-30 , C/C++. , Google, ́ Java C++[15][16][17].

, Java, , , .[18] CLI, .NET Microsoft.

[]

[] Java 1.0

Java 1990 ,   Java 1.0,  1996 .

[] Java 1.2

1998  JDK 1.2, Java 2.   strictfp. :

[] Java 2

. , , Beginning Java 2 by Ivor Horton (Mar 1999), JDK 1.2 (   Java 2). , , : . . , . . , . . . Java 2. (2011).

, , , Java 2 , , Java . JDK 1.2 Java 2, Java 2 JDK 7, .

[] Java 5.0

Java 5.0 2004 . C , Java 1.5 Java 5.0. Sun   1.x. , «Update» «u», Java Development Kit 5.0 Update 22. , API, JVM.

:

  • (. enum). Java C++, .
    • Java, , , , .
    • .
    • , , , , , , .
  •   , , . .   Java-.
  • (. generics)  , Eiffel ( C#, C++), . Java.
  • .
  • Autoboxing/Unboxing  Java - (, int  Integer). , .
  • .
  • (, . foreach).
  • Javadoc-, .

[] Java 6

11 2006 .   6.0 6. Java 5.0 , Java SE Development Kit 6 Update 27.


[] Java 7

28 2011 [19]. Java SE 7 . ( «»)[20], : Java SE 7 ( , Jigsaw, Coin) Java SE 8 ( ), 2012 .

, Java SE 7 (Java Platform, Standard Edition 7), . , , Java SE 7 JDK, OpenJDK, Oracle Java, JCP (Java Community Process) OpenJDK. Oracle Java SE 7 OpenJDK, GPLv2 GNU ClassPath, . Java, Coin, , Ruby, Python JavaScript, URL, XML-, JAXP 1.4, JAXB 2.2a JAX-WS 2.2 [21].

5 Java SE 7 , Java . Oracle , , (Java 7 Update 2) [22].

[]

  • - (InvokeDynamic)  JVM ( -), Java - .
  • class-  class- 51 (SE 7) typechecking ; JVM .
  • Java (Project Coin)  Java, :
    • String switch.
    • try (try-with-resources)  AutoCloseable.
    • catch (multi-catch exceptions)  catch ( | | ).
    • (rethrowing exceptions)  «» .
    • .
    • Java generic .
    • (binary literals)  «0b» , .
    • varargs  .
  • (class-loader)  .
  • , URLClassLoader.
  • (JSR 166y).
  • Unicode 6.0.
  •   .
  • I/O Java (nio.2).
  • JDBC 4.1 Rowset 1.1.
  • ( )

[] Java

Java :

  • Java SE  Java Standard Edition, Java, , API, Java Runtime Environment; ,   .
  • Java EE  Java Enterprise Edition, .
  • Java ME  Java Micro Edition, , , , , ;
  • JavaFX  , Java Rich Client Platform; .
  • Java Card  , - .

[] Java Microsoft

Microsoft JVM (MSJVM[23]), , Windows 98 ( Internet Explorer 3 , MSJVM Windows 95 Windows NT 4 IE3+ ).

MSJVM c Sun Java, :

Java DCOM Win32 . Sun Microsystems Microsoft. Sun Microsystems. Microsoft JVM 2007 , .[23]

2005 Microsoft .NET Java- J#, Java Microsoft Visual Studio, Visual Studio 2008[24].

[] Java

Java (J2EE) : RuneScape, Amazon[25][26], eBay[27][28], Yandex ( Java)[29][30], LinkedIn[31], Yahoo![32].

Java (J2EE) : SAP, IBM, Oracle. , Oracle JVM , Java, , , .[33]

[]

, Java, , [   237 ]. , , Java, 19971998 JIT- 1.1 ( , StringBuffer,  . .). Java  2000 HotSpot. [], Java 2.0 2 , C[   237 ]

Java[   237 ]. , Java JVM, ARM , Java Jazelle.

[]

  • ( 1.5);
  • .

[]

Java-.

[]

, «Hello, world!»:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

generics:

import java.util.*;
public class Sample {
    public static void main(String[] args) {
        //    .
        List<String> strings = new LinkedList<String>();
        strings.add("Hello");
        strings.add("world");
        strings.add("!");
        for (String s : strings) {
            System.out.print(s);
            System.out.print(" ");
        }
    }
}

reflection:

import java.lang.reflect.Field;
import java.lang.reflect.Method;
 
class TestClass {
    private int value;
    public int getValue() { return value; }
    public void setValue(int value) { this.value = value; }
}
 
public class Main {
 
    public static void main(String[] args) {
        TestClass testClass = new TestClass();
 
        for (Field field: testClass.getClass().getDeclaredFields()) {
            System.out.printf("name: %s, type: %s \n", field.getName(), field.getType().getCanonicalName());
        }
 
        for (Method method : testClass.getClass().getDeclaredMethods()) {
            System.out.printf("name: %s, return type: %s  \n", method.getName(), method.getReturnType().getCanonicalName());
        }        
    }
}

:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
 
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Annotation {
 
    public boolean value() default false;
 
}
 
@Annotation(value=true)
public class TestClass {
 
}
 
public class Main {
 
    public static void main(String[] args) {
        TestClass testClass = new TestClass();
 
        Annotation annotation = testClass.getClass().getAnnotation(Annotation.class);
        if (annotation != null) {
            System.out.printf("value: %s \n", annotation.value());
        }
    }
}

[]

[]

Java 8 (, ) : boolean, byte, char, short, int, long, float, double.   void, , , . , Void , void: Hello.class.getMethod("main", Array.newInstance(String.class, 0).getClass()).getReturnType() == Void.TYPE.

, . char ( Java): , Unicode-16, Unicode-32. , byte, Java, , . float double +\infty, -\infty « » (NaN). double Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NaN; float  , Float Double. , float double, .

( )
boolean 1 , 4 [34] true, false
byte 1 128..127
char 2 0..2161, 0..65535
short 2 215..2151, 32768..32767
int 4 231..2311, 2147483648..2147483647
long 8 263..2631, 9.2·1018..9.2·1018
float 4 -(2-223)·2127..(2-223)·2127, 3.4·1038..3.4·1038, -\infty, \infty, NaN
double 8 -(2-252)·21023..(2-252)·21023, 1.8·10308..1.8·10308, -\infty, \infty, NaN

, -, Java. . 10- . , Java , . . , , . , strictfp, .

[]

Java :

  1. double, double.
  2. , float, float.
  3. , long, long.
  4. int.

C++.[35]

[] , ,

Java . Java  . , . . , Java :

double a[10][20];
Foo b(30);

:

double[][] a = new double[10][20];
Foo b = new Foo(30);

, , , .   , .

, . Java . C, C++ , Java , :

  • int .
  • ++, , +, .
  • . , , . , , .
  • Java (&) (*). Java , . (&) « » (   « »). « », , false[36] (. a == b && foo() == bar() foo() bar() , a != b, & .

Java ( , , : null).

, - : Boolean, Byte, Character, Short, Integer, Long, Float, Double.

[]

- , , . ,

Foo foo, bar;

bar = foo;

foo bar. foo bar , ; , foo, , bar, . , (-, C++) clone(), , () ( Java , - -; ).

clone() , Cloneable ( . ). Cloneable, clone() ( ). , ( ), clone(). clone() .[37]

[]

Java   . [   926 ] , «» , null. , , , , null, , , . , . , , . , , , .

[]

Java : . Java, «» «-» (. member function), . . , Java sin(), Math.sin() Math (, sin(), cos(), exp(), sqrt(), abs() ). Java . Java , finalize() .

[]

Java ( C++) (. static method  ), static. ( ) , C++: , .

, , Math, .

double x = Math.sin(1);

Math m = new Math();
double x = m.sin(1);

( ), () . , this.

[] (final)

final () , . , (   ) . , , final, . , . , , , ; switch ( int), ( boolean) if.

, final, . .

[]

Java , static, final private, C++: , - , .

( abstract) Java , , . -. C++ . , . .

[]

Java (interface). : abstract . Java , . / (extends) (implements) . , / .

Java , . , .

, .

[]

Java , , JVM. :

  • java.lang.Cloneable
  • java.io.Serializable
  • java.rmi.Remote

[] Java (generics)

Java 5   , C++. -, , .

//   
class GenericClass<E> {
  E getFirst() { ... }
  void add(E obj) { ... }
}
 
//     
GenericClass<String> var = new GenericClass<String>();
var.add("qwerty");
String p = var.getFirst();

, . , -: <T extends A & B & C...> , - T A, B, C , <T super C> , - T C .

C#, Java   -, . Java C++: -, -, . Java.

[]

Java , . foo instanceof Foo , foo Foo , Foo (, , , , Foo).

, getClass(), , Class. Class, . , , foo.getClass() == bar.getClass() , foo bar ( ).

, Class : Integer.class, Object.class.

. isAssignableFrom(). Class Class . , Foo.class.isAssignableFrom(Bar.class) true , Foo Bar. Object, Object.class.isAssignableFrom() true.

Class isInstance() ( instanceof), cast() ( ).

[]

[]

[] .

[]

  1. Java SE 7 Is Here!  (.). Oracle Corporation. 22 2011. 28 2011.
  2. Java Was Strongly Influenced by Objective-C
  3. White Paper. About Microsofts «Delegates»
  4. History of Java in Java Application Servers Report TechMetrix Research, 1999
  5. (PC World Russia CD, September 2005)
  6. . . . . 
  7. Java 5.0 (foreach, autoboxing, varargs ), , ( ) C#; .: http://www.barrycornelius.com/papers/java5/ http://www.levenez.com/lang/
  8. Gosling, McGilton. The Java Language Environment. ( 1996). 22 2011.  ???.
  9. J. Gosling, B. Joy, G. Steele, G. Brachda. The Java Language Specification, 2nd Edition. . 22 2011.  ???.
  10. The A-Z of Programming Languages: Modula-3  a-z of programming languages  Computerworld
  11. Java. .. 6 2009.
  12. «» Sun Tech Days. Youtube. 28 2010.
  13. 2009  (.). Java Users Group. 22 2011. 6 2009.
  14. Java 6 -server speed ÷ C++ GNU g++ speed | Computer Language Benchmarks Game
  15. Metz, Cade Google pits C++ against Java, Scala, and Go  (.). The Register (3 June 2011). 22 2011. 5 2011.
  16. Loop Recognition in C++/Java/Go/Scala (PDF, 0.3 )
  17. Google C++, Java, Go Scala
  18. Robert Tolksdorf. Programming languages for the Java Virtual Machine JVM  (.). is-research GmbH.  - JVM. 22 2011. 5 2009.
  19. JDK7
  20. Oracle Java SE 7  (.)
  21. Index corruption and crashes in Apache Lucene Core / Apache Solr with Java 7  (.)
  22. 1 2 Microsoft Java Virtual Machine Support  (.). Microsoft (12 2003).  Microsoft MSJVM. 22 2011. 9 2010.
  23. Visual J#  (.). Microsoft ( 2007).  Microsoft J# Visual Studio 2008. 22 2011. 10 2010.
  24. Todd Hoff. Amazon Architecture  (.) (18 2007).  Amazon Java-. 6 2009.
  25. Amazon Elastic Compute Cloud (Amazon EC2)  (.). Amazon Web Services LLC.  Amazon EC2 -. 22 2011. 6 2009.
  26. Todd Hoff. eBay Architecture  (.) (27 2008).  eBay Java. 22 2011. 6 2009.
  27. Randy Shoup, Dan Pritchett. The eBay Architecture  (.). SD Forum 2006.  ??? (29 2006).  eBay. 22 2011. 6 2009.
  28. Allen Stern. Exclusive Interview With Yandex CTO Ilya Segalovich  (.). CenterNetworks (14 2008).  . 22 2011. 6 2009.
  29. . .  (.) (PowerPoint). JUG .  ??? (24 2008). 22 2011. 6 2009.
  30. Brian Guan. The LinkedIn Blog. Blog Archive. Grails at LinkedIn  (.). LinkedIn.com (11 2008).  LinkedIn Java- Grails. 22 2011. 5 2009.
  31. Hadoop and Distributed Computing at Yahoo!  (.). Yahoo!.  Java- Hadoop Yahoo!. 22 2011. 21 2009.
  32. OracleJVM and Java Stored Procedures  (.). Oracle Inc..  Oracle, Java Oracle. 22 2011. 5 2009.
  33. JVM boolean, int. boolean[] . VM Spec The Structure of the Java Virtual Machine
  34. . ++ = The C++ Programming Language.  ..: , , 2008.  1104 .  5000 .  ISBN 5-7989-0226-2; ISBN 5-7940-0064-3; ISBN 0-201-70073-5
  35. Java Language Specification Third Edition  http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.22.2
  36. Object (Java 2 Platform SE v1.4.2)  (.). Sun Microsystems.  Object.clone(). 22 2011. 6 2009.
  37. Pulsar - Eclipse Mobile Tools Platform  (.). Eclipse.  eclipse . 22 2011. 23 2011.

[]

[]

«java»