28 July 2012

                                                                       Tutorial #2
  Few important properties of java that needs to be learn &   
  understand by all java programmers whether he/she is beginner or
  professional.so here it goes:-

*java is the first programming language that is independent of hardware for its running & work on any configuration or OS(operating system)
      This is mainly because java does-not run on host computer directly,it runs on java virtual machine by converting the program into byte code that are machine independent & that virtual machine converts the byte code according to the configuration requirement type.

*Java does-not use pointers, preprocessor header files,go-to statement & many others .It also eliminate operator overloading that sometime may create chaos in programming.

*Java programs also support functions written in another common languages like C & C++. These functions are called by some special names called as native method.

*java also doesn't include C unique statement keyword sizeof, typedef  & also data type like struct & unions  .Neither do it has include pre-processor directives like #define,#include,#ifdef.
      Instead of this it import statement ,but that use to work much differently than # include as it is attached dynamically at run -time.

*Java also don't have template class as it is present in C++;
                                     
                                                     Overview of Java
 Java in its broad sense has three parts:-
1.J2SE  {Core java + Advance java }
            (that is mainly same as any other primitive language in its rudimentary form like C & C++
             that works as a standalone feature that works on individual computer)
2.J2EE
           (this is mainly for application development that helps in developing website & adding amazing        
             functionality in it )
3.J2ME
           (this mainly helps in developing apps & games of mobile phone & has a great rising market now a
             days when android apps are becoming so popular)

 But for learning any particular branch of java core java of J2SE is very helpful  & must in some sense so we start with learning J2SE.
         Note that :- *java is pure object oriented language unlike C or C++ (which supports both) . So everything we wrote in java must be inside the class.
                            *Also unlike C++ class definition in java doesn't ends with semi-colon(;)
                            * A java application may have any number of classes but only one of them should have main method & program starts from execution of that calls & will end with the execution of that class & if that class links other classes in its body then they intern will also gets executed.
                            * there are three ways of commenting in java
                                      1. // this will allow commenting for only one line;
                                      2. /* comment */ this will allow commenting for more than  one line
                                      3./*comment
                                          *comment continue
                                          *comment continue
                                          */
Lets end this lecture with developing our first programm:-
//This program simply calculate the square-root of first ten natural numbers :-
__________________________________________________________________________
import java.lang.math;
class SquareRoot
{
     public static void main(String args[])
           {
                    double m;
                    double y;
                    for(int i=0;i<=10;i++)
                    {
                              y=Math.sqrt(i);
                              System.out.println("The square root of"+i+" =  "+y);         
                     }

            }
}

_______________________________________________________________________________
The best software for programming java is MyEclipse that can be downloaded from the given below site:-

And tutorial for writing program in MYEclipse can be sen from the given below sites:-


(remaining we will discus in the next tutorial)





No comments:

Post a Comment