Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Simon Kroly
simon.karoly@codespring.ro
The Java programming language
7/11/2016 2
Java history in a nutshell
7/11/2016 3
Java history in a nutshell
1998 J2SE 1.2 (Java 2 Platform Standard Edition) (JDK 1.2), J2EE
(Java 2 Platform Enterprise Edition), J2ME (Java 2 Platform Micro
Edition)
J2EE: application servers, component-based development, distributed
systems, web applications (EJB Enterprise Java Beans, JPA Java
Persistence API, JTA Java Transaction API, JMS Java Message
Service, Servlet API, JSP JavaServer Pages, JSF JavaServer Faces
etc.)
2005: there are 2.5 billions of electronic devices running Java,
approximately 4.5 millions of developers using Java.
2009-2010: the Sun Microsystems was bought by Oracle
There are more than 1 billion JRE downloads in a year, more than 10
millions of developers using Java, billions of devices running Java
(more than 3 billions of mobile devices).
7/11/2016 4
Java history in a nutshell
7/11/2016 6
Main principles
Platform independency
Reliability:
E.g.: desktop application failure vs. mobile phone/ATM software
failures the aim is to reduce the possibility of programmers
mistakes, programming errors.
Only objects are used as data structures.
Proper exception handling.
No multiple inheritance.
Garbage collector
Security
No pointer arithmetic, no uncontrolled access to the memory.
Sandbox mechanism.
7/11/2016 7
Beyond the stage
7/11/2016 9
Example
Primitive data types: byte (signed integer, 8 bit), short (signed integer, 16
bit), int (signed integer, 32 bit), long (signed integer, 64 bit), char (16 bit
Unicode character, UTF16 encoding), float (floating point, 32 bit), double
(floating point, 64 bit), boolean (the value can be true or false, the size is
not specified, it is JVM-dependent).
Wrapper classes: Byte, Short, Integer, Long, Character, Float, Double,
Boolean
Examples:
int i1 = 5; i2 = new Integer(i1);
Integer i2 = new Integer(5); float f = i2.floatValue();
Integer i3 = new Integer(i1); char c = a;
String s = "10"; if (Character.isLowerCase(c))
int i1 = Integer.parseInt(s); c = Character.toUpperCase(c);
7/11/2016 11
Reference type
String s1 = "Hello";
String s2 = s1;
String s3;
s3 = new String("Hello");
The implicit value for a reference is null. Memory allocation for the
referenced object is done using the new operator.
7/11/2016 12
Reference type
7/11/2016 13
Autoboxing and auto-unboxing
7/11/2016 14
Arrays
try {
// Could throw exception
} catch(Exception1 object1) {
// Handling an exception of type Exception1
} catch(Exception2 object2) {
// Handling an exception of type Exception2
} finally {
// Will be always executed
}
7/11/2016 16
Exception handling - example
7/11/2016 17