Java Tutorial

This tutorial covers all the topics of Java Programming language. In this section you will learn about what is Java, download java, Java environment set up, features of Java, keywords in Java, data types in Java, conventions in Java, Java identifiers, access specifiers, variables in Java, Java literals, Java operators, conditional statements, loops in Java.

Ads

Tutorials   
Java Programming Examples Read file line by line in Java 8 What are the benefits of learning Java Programming? A brief history and future of Java programming language Importance of Java for Mobile Application Development How To Become A Good Software Developer? Learn Java Programming for beginners 5 Reasons Java is Still a Great Language to Boost Your Career Prospect as a Programmer How to learn Java with no programming experience? How to learn Java? What are Classes and Interfaces in Java? Converting a String to Integer in Java How to check if a string exists in a string in JavaScript? Installing JDK 8 on Windows 10 and configuring the settings Video Tutorial of reading file in Java 9 Invincible Reasons to learn Java New to Java programming Java Programming Tips, Articles and Notes How to download JDK 1.6? Encapsulation in Java Programming How to format number in Java? Generics Example Program in Java Java 9 Features Java 9 Tutorial, news and examples How to read content of JPEG file in Java? Image Processing Tutorials in Java Programming Language Introduction to Java Technology Java 8 Consumer Interface with forEach Loop Introduction to Generics in Java Java 8 consumer class(interface) example Oracle Launches Project Valhalla for Java How to read properties file in Java? How to add JDK 8 support in Eclipse? Java 8: Java 8 is officially released and it can be downloaded How to Invoke method using Reflection API of Java? First Lambda Expressions in Java Java 8 expected release date Lambda Expressions example in Eclipse JDK 8 Release Candidates Available Lambda Calculus Lambda Expression in Java 8 How to learn Java easily? Java made easy Oracle to release Java 8 in March 2014 Object Oriented Programming in Java Java Training Free Java beginners Course Easiest way to learn Java Tutorials on Java JDK 8 - Developer Preview Released
Ads

In this section we will discuss about the Java Programming Language.

This tutorial covers all the topics of Java Programming Language. In this section you will learn about what is Java, Download Java, Java environment set up, Features of Java, keywords in Java, DataTypes in Java, conventions in Java, Java identifiers, access specifiers, Variables in Java, Java literals, Java operators, conditional statements, loops in Java.

what is Java ?

Java is a programming language based on the OOPs concept. It is a simple, secure and platform-independent language. It supports Multi-threading, distributed, and dynamic application. Applications developed using Java Programming Language are robust, portable, and their performance is high. It was developed by James Gosling and released by the Sun Microsystems in 1995. Java is called an emerging language because most of the syntaxes used in it are derived from the programming language 'C' and 'C++'. Java is written in such a way that it facilitate developer to write code in "write once run anywhere" (WORA) manner i.e. if a code is written on one platform and it is running over there then it can be run on another platform without recompiling there. Java is available as an open source under the GNU General Public License.

Download Java

Java can be downloaded from the Oracle sites, an official website for Java. You can go through the link for downloading latest version of Java http://www.oracle.com/technetwork/java/javase/downloads/index.html then select the license acceptance agreement.

Java Environment Set Up

To run Java in your system you have to set up the environment. You can set up environment according to your platform i.e. O/S (Operating System). For example

  • Environment Set Up for Windows
  • Linux

Features of Java

Java has various features, these are as follows :

  • Simple
  • Object Oriented
  • Compiler and Interpreter
  • Platform Independent
  • Secure
  • Robust
  • Distributed
  • Multithreaded
  • Dynamic
  • Architectural Neutral
  • High Performance

Keywords In Java

Keywords are the reserve word for doing specific task the programming language's compiler understands. Java has also keywords some of these are as follows :

abstract, assert, boolean, break, byte, case, catch, char, class, const, continue, default, do, double, else, enum, extends, final, finally, float, for, goto, if, implements, import, instanceof, int, interface, long, native, new, package, private, protected, public, return, short, static, strictfp, super, switch, synchronized, this, throw, throws, transient, try, void, volatile, while.

DataTypes in Java

Java allows two types of data types these are as :

  1. Primitive Data Types: In Java there are eight primitive data types these data types are predefined by the language.
  2. Reference Data Types: Reference data types are the data types that contains the reference of any object of the declared type or any compatible type. for example Bicycle bicycle = new Bicycle(); Here bicycle is a reference data type variable.

Conventions In Java

Java is a case sensitive language it follows the conventions for declaring or defining the classes, methods, interfaces etc. To use the predefined data types, classes, methods, interfaces etc. we must have to follow as they are defined or declared.

Java Identifiers

Assigning a name to a Java component is called identifiers, For example assigning name to a method, classes, and variables. An identifiers should follow the following tips :

  • Should be started with an alphabetic character, $, or an underscore (_) then the following character identifiers can contain any combination of characters.
  • An identifier mustn't be a Java keyword.
  • Identifiers in Java are case sensitive.

Access Specifiers

Access specifiers or modifiers explains the accessibility of Java component like, class, methods, variables, etc. There are two types of access modifiers these are :

  • Access Modifiers : Specifies the scope of accessibility like, default, public, protected, private.
  • Non-access Modifiers : Specifies the non accessibility like, final, abstract, strictfp.

Variables in Java

There are three types of variables in Java.

  • Instance variables
  • Class variables
  • Local variables

Java literals

Literals in Java represents the fix value. They can be used directly in Java Code for example, '\t' for tab space, '\b' for backspace, '\n' for newline etc.

Java Operators

Programming languages provides operators for manipulating variables. Java also have a set of operators for manipulating variables. These operators can be categorized as :

  • Arithmetic Operators : '+', '-', '*', '/', '%'
  • Relational Operators : '= =', '!=', '>', '<', '>=', '<='
  • Bitwise Operators : '&', '|', '^', '~', '<<', '>>', '>>>'
  • Logical Operators : '&&', '||', '!'
  • Assignment Operators : '=', '+=', '-=', '*=, '/=', '%=', '<<=', '>>=' etc.
  • Increment Operator : '++'
  • Decrement Operator : '--'
  • Ternary Operator : '? : '

Conditional Statement

Conditional statements are the statements used for testing the conditions. if, nested if, if-else, if-else if, nested if-else if etc. are called the conditional statements.

Loops In Java

Java provides loops to execute the statements repeatedly in a controlled way. These loops are as :

  1. while loop
    1. while loop : while loop provides to execute the statement repeatedly till the statement satisfies the condition given as parameter of while loop. while loop can be written as :
    2. initialization;
      while(condition/boolean expression)
      {
        //statement
      }
      increment/decrement;
      		
    3. do....while loop : do....while loop is same as while loop but the only difference is that the do...while loop statement will execute once either it satisfies the condition or not whereas, while loop will execute only when it satisfies the condition do...while loop can be written as .
    4. do{
        //statement
      }
      while(condition/boolean expression);
      		
  2. for loop
    1. for loop : for loop provides a simple way to execute the statement repeatedly till the statement satisfies the condition given as parameter of for loop. for loop can be written as :
    2. for(initialization; condition/boolean expression; increement/decreement)
      {
       //statement
      }
      		
    3. Advanced for loop (for each loop) : for each loop is introduced since Java 5, and is basically used to traverse the elements in array or a collection. for-each loop can be written as :
    4. for(data_type variable : array/collection)
      
      {
        //statement
      }
      		

Advertisements

Ads
Share on Google+Share on Google+

Java Tutorial

Posted on: April 23, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Java Tutorial  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads