Sie sind auf Seite 1von 4

Introduction to 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 byte code 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 clientserver 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 process of planning and creating a program is called programming.
Java is secure: Java was designed to allow secure execution of code across
network. To make Java secure many of the features of C and C++ were eliminated.
Java does not use Pointers. Java programs cannot access arbitrary addresses in
memory.
The basic elements of Object Oriented Programming (OOP) include
Polymorphism, Data Encapsulation, Inheritance, Class, Object, Data Hiding,
Data- Abstraction etc.
Abstraction: Abstraction denotes the essential characteristics of an object that
distinguish it from all other kinds of objects and thus provide crisply defined
conceptual boundaries, relative to the perspective of the viewer.
Encapsulation: Encapsulation is the process of compartmentalizing the elements
of an abstraction that constitute its structure and behavior. Encapsulation serves to
separate the contractual interface of an abstraction and its
implementation.

* Hides the implementation details of a class.


* Forces the user to use an interface to access data
* Makes the code more maintainable.
Inheritance: Inheritance is the process by which one object acquires the
properties of another object.
Polymorphism: Polymorphism is the existence of the classes or methods in
different forms or single name denoting different implementations.
Data hiding: Data hiding is a software development technique specifically used in
object-oriented programming (OOP) to hide internal object details (data
members). Data hiding ensures exclusive data access to class members and
protects object integrity by preventing unintended or intended changes. Data
hiding also reduces system complexity for increased robustness by limiting
interdependencies between software components.
Iteration through loops: A loop statement allows us to execute a statement or
group of statements multiple times. Various loops used are for, while and do while.

For loop- Execute a sequence of statements multiple times and abbreviates


the code that manages the loop variable.
While loop- Repeats a statement or group of statements while a given
condition is true. It tests the condition before executing the loop body.
Do while loop- Like a while statement, except that it tests the condition at
the end of the loop body.
Decision making: Decision making structures have one or more conditions to be
evaluated or tested by the program, along with a statement or statements that are
to be executed if the condition is determined to be true, and optionally, other
statements to be executed if the condition is determined to be false. The basic
statements used are if, if-else, switch etc.
Strings: A string is group of characters separated by a space. There are many
string functions and string manipulation statements to change the case, replace,
insert a letter or checking two strings. Some of the string functions are length(),
CharAt(), IndexOf(), Substring() etc.

Arrays: Java provides a data structure, the array, which stores a fixed-size
sequential collection of elements of the same type. An array is used to store a
collection of data, but it is often more useful to think of an array as a collection of
variables of the same type. Arrays are basically divided into two types: One
Dimensional and Two Dimensional.

One dimensional array- A one-dimensional array (or single dimension


array) is a type of linear array. Accessing its elements involves a single
subscript which can either represent a row or column index. It is declared by
the statement- int array[]=new int[10]; where 10 represents number of
rows/columns.
Two dimensional array- A two dimensional array lends itself to a visual
display in rows and columns. The first index represents a row, and the
second index represents a column. It is declared by the statementint array[][]=new int [5][6] where 5 is number of rows and 6 number of
columns.
Sorting: Java provides features to sort the elements(either numbers or characters)
of an array in ascending or descending order. Different types of sorting techniques
provided in java are:

Selection sort- In this technique, successive rounds are executed to select the
elements in some order and place them into their positions.
Bubble sort- This technique is widely used for sorting elements. In this
technique, the array is sequentially scanned several times and during each
iteration, the pairs of consecutive elements are compared and interchanged,
if necessary, to bring them to a specific order.
Insertion sort- It is based on the principle of insertion of the elements in the
required position.
Merge sort- In this technique, elements of two arrays are merged into a
single array and then the merged array is sorted in order using any of the
above techniques.
Searching: It is a process to determine whether a given item is present in an array
or not. This can be done in two ways:

Linear search- It is one of the simplest techniques in which searching of an


item begins at the start of an array. This process continues one after another
where each element of the array is checked and compared with given data
item till the end of array is reached.
Binary search- In this technique, an array is divided into two halves and
then then the required element is searched either in the left half or right half
depending upon the middle element.
Recursion: Java supports recursion. Recursion is the process of defining
something in terms of itself. As it relates to java programming, recursion is the
attribute that allows a method to call itself.
Data Structures: It is a concept of creating logical structures in the memory in
such a way that by using small space of the primary memory numerous data items
could be stored. Such structures are- array, stack, queue, linked list, tree etc.

Stack: It is a memory structure which is similar to a single dimensional


array but is used with certain restrictions that only one end is open for entry
and exit of data and no element can be accessed from any middle cell. Stack
follows LIFO (Last In First Out) nature i.e. the data which has entered the
stack last will come out first.
Queue- It is a linear data structure which is used simply as a single
dimensional array but followed with certain restrictions. Basically, it
follows FIFO (First In First Out) nature i.e. the data entering first will leave
the queue first.
Dqueue- It is referred as double ended queue in which insertion and deletion
of the data items can be performed at both the ends unlike normal queue.
Linked list- A linked list is a non-linear data structure which allows you to
avail the facilities of storing the data items in randomly available empty
spaces and linking them together in such a way that the manipulation can be
done simply as an array. There are two types of linked list: Singly linked list
which is a connection of various lists in such a way that each list has the
address of the next list and Doubly linked list in which the lists are
connected in such a way that each list possesses the address of both the
proceeding and following list.

Das könnte Ihnen auch gefallen