Java Programing laungage

Core Java Tutorial

Introduction of Core Java

How To Install JDk and Set of Path

Syntax of java Program

Difference between Java and C/C++

Advantage and Disadvantage of Java

What is Java

Why Java is not Pure Object Oriented Language

Java has Following Features/Characteristics

Limitation of Java Language and Java Internet

Common Misconception about Java

Simple Program of Java

Integrated Development Environment in java

Compile and Run Java Program

Applet and Comments in Java

Tokens in Java

Keywords in Java

Identifier and Variables in Java


Data Type in Java

Assignments and Initialization in Java

Operators in Java

Rule of Precedence in Java

Operator on Integer and Separators in Java Programming

Java Control Flow of Statements

If and If-else Selection Statement

Nested If-else and If-else-If Selection Statement

switch case and conditional operator Selection Statement

for and while Loop

do..while and for each Loop

break and labeled break statement

continue and labeled continue statement

return Statement and exit() Method

Escape Sequence for Special Characters and Unicode Code

Constants and Block or Scope

Statement in Java

Conversions between Numeric Types in Java

Import Statement in Java

User Input in Java using Scanner Class

User Input in Java using Console Class

Array in Java

One Dimensional Array

Two Dimensional Array

Two Dimensional Array Program

Command Line Argument in Java

String args Types in Java

Uneven/Jagged array in java

Math Class Function and Constant

Math Class all Function used in a program

Enumerated Types in Java

Object Oriented Programming v/s Procedural Programming

Object Oriented Programming Concepts in Java

Introduction to Class,Object and Method in Java

Class Declaration in Java

Class & Objects in java

Encapsulation in Java

Modifiers/Visibility for a Class or Interrface or member of a Class

Polymorphism in Java

Runtime polymorphism (dynamic binding or method overriding)

Jdk1.5 new Features
Previous Home Next

Here are some new extra Features of Jdk1.5 as follows:


provides compile-time (static) type safety for collections and eliminates the need for most typecasts (type conversion).

Problem: Collection element types

  • Cannot be checked at compile time
  • Assignment must use cast
  • Can cause runtime errors ( ClassCastException)


  • Tell the compiler what type your collection is
  • Compiler can fill in casts for you
  • Guaranteed to succeed.

Generics are NOT templates:

  • No code size increase
  • No hideous complexity
  • No "template metaprogramming"
Enhanced for each loop

The for loop syntax is extended with special syntax for iterating over each member of either an array or any iterable, such as the standard collection classes fix the previously broken semantics of the java memory model, which defines how threads interact through memory.

Enhanced for Loop (for each):


  • Iterating over collections is tricky
  • Often, iterator only used to get an element
  • Iterator is error prone (Occurs three times in a for loop)
  • Can produce subtle runtime errors.

Solution: Let the compiler do it, New for loop syntax for (variable : collection)


Also called annotations; allows language constructs such as classes and methods to be tagged with additional data, which can then be processed by metadata-aware utilities.


  • Some APIs require lots of standard code
  • How to indicate this to a tool

Solution: Annotated source code e.g. @remote getPrice(Product p)

Auto boxing/unboxing

Automatic conversions between primitive types (such as int) and primitive wrapper classes (such as integer).

Auto-boxing of primitive types:


  • Conversion between primitive types and wrapper objects (and vice-versa)
  • Needed when adding primitives to a collection

Solution: Let the compiler do it

Integer intObj = 22; // Boxing conversion
int i = (int)intObj // Unboxing conversion
ArrayList al = new ArrayList();
al.add(22); // Boxing conversion


The enum keyword creates a typesafe, ordered list of values (such as day.monday, day.tuesday, etc.). Previously this could only be achieved by non-typesafe constant integers or manually constructed classes (typesafe enum pattern).

Typesafe Enumerations:


  • Variable needs to hold limited set of values
  • e.g.Card suit can only be Spade, Diamond, Club, Heart

Solution: New type of class declaration

  • enum type has public, self-typed members for each enum constant
  • new keyword, enum
  • works with switch statement.
Var args

The last parameter of a method can now be declared using a type name followed by three dots (e.g. Void drawtext(string... Lines)). In the calling code any number of parameters of that type can be used and they are then placed in an array to be passed to the method, or alternatively the calling code can pass an array of that type.

Varargs Problem:

  • To have a method that takes a variable number of parameters
  • Can be done with an array, but not nice
  • Look at java.text.MessageFormat

Solution: Let the compiler do it for you

  • New syntax: public static String format(String fmt, Object... args);
  • Java gets printf !!!.
Static imports


  • Having to fully qualify every static referenced from external classes

Solution: New import syntax

  • import static TypeName . Identifier ;
  • import static Typename . * ;
  • Also works for static methods and enums e.g Math.sin(x) becomes sin(x)
Concurrency Utilities
  • Goal: Beat C performance in high end server side applications
  • New framework for locks to provide greater flexibility over synchronized
  • No more threads, use Executors
  • Use anExecutor.execute(aRunnable)
  • Not new Thread(aRunnable).start();
  • Runnable and Callable
  • Callable for things that return values and/or exceptions
Previous Home Next