Java is a general-purpose, object-oriented programming language developed by Sun Microsystems, with James Gosling being a key contributor. It builds on the foundation of C and C++ but introduces key enhancements to simplify and modernize programming.
Flow of control
switch
for, while, do-while
break
continué
Array types Variables
dataType identifier[ = Expression]:
Example variable declarations and initializations
Data types
8 primitive types:
boolean, byte, short, ¡nt, long, float, double, char Class types, either provided by Java, or made by programmers
String, Integer, Array, Frame, Object, Person, Animal, ...
features
Dynamic
java ¡s designed to adaptto evolving environment
librarles can freely add new methods and ¡nstance variables
without any effect on their clients
Multithreaded
múltiple concurrent threads of executions can run simultaneously utilizas a sophisticated set of synchronization primitivas (based on monitors and condition variables paradigm) to achieve this
Object oriented
- Focus on the data (objects) and methods manipulating the data.
-all funtions are associated with objects.
-almost all data types are oblects (feles strings, etc)
-potentially better code organizations and reuse
Interpreted
- Java compiler generate byte-codes, not native machine code
-The compiled byte-codes are plattaform independent
-Java byte codes are translated on the fly to machine readable instrucions runtime (java virtual machine).
Simple
- Fixes some clumsy features of C++
no pointers
-automatic garbe collection
Subtopic
Java Disadvantages
Slowerthan compiled language such as C
an experiment ¡n 1999 showed that Java was 3 or4 times slower than C or C++
tille ofthe aiiicle: "Comnaríng Java vs. C/C++ Efficiencv Issues to Interpersonal íssues" (Lutz Prechelt)
adequate for all bul the most time-intensive programs
WHAT IS JAVA?
Developed by Sun Microsystems (James Gosling).
A general-purpose object-oriented language.
Based on C/C++
Designed for easy Web/Internet aplications.
Widespread acceptance.