What is Java SE ( Java standard Edition )

JAVA

 

Java SE or Java Standard Edition is the widely used object-oriented programming language to develop and operate web-based or system-based applications. It is an eminent programming language used typically to implement several types of applications like the web application, mobile application with iOS & Android and UI oriented applications. Java is chosen over other programming languages due to its salient qualities, including the high performance, portable, robust, platform-independent, multithreading, distributed system, highly secure, etc.

What is JDK and How to Install it ?

JDK is an implementation of any one of the below given Java Platforms released by Oracle corporation: The JDK contains a private Java Virtual Machine (JVM) and a few other resources such as an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc) etc. to complete the development of a Java Application.  https://www.python.org/ 

  Step 1: Download JDK from the Site

  • Go to the Oracle site and open the Java SE download page. Under the latest version of Java Platform, Standard Edition, click on the JDK download button.


Step 2: Install the JDK exe File

  • In this step, we will be running the executable JDK file (It will be a file with .exe as an extension) once the download is done. This installs JDK as well as JRE. For running this file on Windows, we will need Administrator rights.
  • To begin the installation, we need to double-click on the downloaded file, and we will be presented with the below window.
  • Click on Next to proceed with the installation, and follow the Installation guide provided for any queries.
  • Click on the Close button once the installation has finished.
 
 

Feature of Java SE

 

————————————— Object oriented programming —————————–

 

What are oops concept in java 

The basic concept of OOPs is to create objects, re-use them throughout the program, and manipulate these objects to get results. OOP meaning “Object Oriented Programming” is a popularly known and widely used concept in modern programming languages like Java. The class is one of the Basic concepts of OOPs which is a group of similar entities.

1)Classes & Objects :

 

Java is an object-oriented programming language.Everything in Java is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. The car has attributes, such as weight and color, and methods, such as drive and brake.

A Class is like an object constructor, or a “blueprint” for creating objects.

Example :

                     class vehicle  {

                                     ———–

                                      ———-

                                          }

                                 OR

                      class Students{

                                     ———–

                                     ————

                                           }

In Java, an object is created from a class. We have already created the class named Students, so now we can use this to create objects.

To create an object of Students , specify the class name, followed by the object name, and use the keyword new:

 2) String 

 

In java string is basically an object that represents sequence of char values. An array of characters works same as Java string. For example:

  1. Char [] ch = {‘F’,’l’,’o’,’u’,’r’,’i’, ‘s’,’e’,’n’,’s’,’e’};
  2. String s= new String(ch);

The Java String is immutable which means it cannot be changed. Whenever we change any string, a new instance is created. For mutable strings, you can use StringBuffer and StringBuilder classes

String s  =  ”flourisense”;

if reassign new string of old string objects so it will create the new object for that string               

                       

                                                           fig: structure of string

 

Example :

public Class StringDemo{

public static void main(String[] args)

{

   String name1 = {“a”,”b”,”c”,”d”,”e”};

   String name2 = new String(“ Flourisense “);

   System.out.println(name1);

   system.out.println(name2);

  }

 }

The out will be :

  1. abcde
  2. Flourisense

Methods of String Class

 

Methods

Description

contains()

checks whether the string contains a substring

substring()

returns the substring of the string

join()

join the given strings using the delimiter

replace()

replaces the specified old character with the specified new character

replaceAll()

replaces all substrings matching the regex pattern

replaceFirst()

replace the first matching substring

charAt()

returns the character present in the specified location

getBytes()

converts the string to an array of bytes

indexOf()

returns the position of the specified character in the string

compareTo()

compares two strings in the dictionary order

compareToIgnoreCase()

compares two strings ignoring case differences

trim()

removes any leading and trailing whitespaces

format()

returns a formatted string

split()

breaks the string into an array of strings

toLowerCase()

converts the string to lowercase

toUpperCase()

converts the string to uppercase

Exeception Handling

Exeception is an unwanted or unexpected event, which occurs during the execution of a program, i.e. at run time, that disrupts the normal flow of the program’s instructions.

This is the way to handle the exception which occurs at runtime execution of a program . we must  have to handle the occur exception for the smooth execution of the program execution is the abnormal condition occurring in a program due to which the normal execution of the program will be stopped. In java the exception  

JAVA the Error and Exception are the child classes of throwable which is parent class.and also Throwable is the child class of Object which is parent class of all java classes.

Fig: Exeception Hierarchy

Example:

Class ExceptionDemo {

public static void main (String [] args)

  try {

         int a= 10/0 ;  // here exception can be occur 

    }

 catch(ArithmaticException e){

      System.out.println(“Execution of rest of the code”) ;   // Catch block which contain the handling code

   }

  finally{

       // This block contain the necessary code which we have to execute 

        }

}

Collection in Java

Java Collection means a single unit of objects. Java Collection framework provides many interfaces (Set, List, Queue, Deque) and classes (Array List, Vector, LinkedList Priority Queue, HashSet, LinkedHashSet, TreeSet).

A Java collection framework provides an architecture to store and manipulate a group of objects. A Java collection framework includes the following:

  • Interfaces
  • Classes
  • Algorithm
Fig : Java Collection Framework

Java Collection : List

A List is an ordered Collection of elements which may contain duplicates. It is an interface that extends the Collection interface. Lists are further classified into the following:

  1. ArrayList
  2. LinkedList
  3. Vector

Array list: ArrayList is the implementation of List Interface where the elements can be dynamically added or removed from the list. Also, the size of the list is increased dynamically if the elements are added more than the initial size.

Example :

ArrayList<> L=new ArrayList<>();

                     OR

ArrayList l=new ArrayList();

           l.add(2);

           l.add(‘a’);

           l.add(“ Flourisense “);

          System.out.println(l)      // output is the elements of Arraylist

Output: 2 , a ,Flourisense 

Singly Linked List: In a singly Linked list each node in this list stores the data of the node and a pointer or reference to the next node in the list. Refer to the below image to get a better understanding of single Linked list.

Doubly Linked List: In a doubly Linked list, it has two references, one to the next node and another to previous node. You can refer to the below image to get a better understanding of doubly linked list.

Java Collections: Sets

A Set refers to a collection that cannot contain duplicate elements. It is mainly used to model the mathematical set abstraction. Set has its implementation in various classes such as HashSet , TreeSet and LinkedHashSet.

Example:


set s = new set();

OR

set<> s=new set();       // Create a empty set using new keyword

s.add(2);                       // Add the element using the object s

s.add(3);                      // Add the element 3 in set

s.add(4);

s.add(5);

System.out.println(s);

                                  //  it will print the elements presents in set

OutPut :   2 ,3 , 4 , 5

Java collections: Queue

Queue in Java follows a FIFO approach i.e. it orders the elements in First In First Out manner. In a queue, the first element is removed first and last element is removed in the end. Each basic method exists in two forms: one throws an exception if the operation fails, the other returns a special value.

Fig: Queue

Example:

Queue q = new Queue();

q.offer(34);      // method to add element in Queue

q.element();    // it will return head element of queue

q.poll();          // It will remove and return the head element

q.remove();    // it will Remove and return head return the head element , but if Queue is empty the it will                                                   raise RuntimeException