Monday, March 6, 2006

Java for Electronics Engineers

So, I am a Java professional now.... Wow, that sounds Awesome.

After spending lots of time trying to understand what it is, joining formal training program, it comes to be a quiet simple stuff. Only thing is that, we, electronics engineers should be taught it in a different way.

Generally trainers start with JVM and OOPS concept and all.... And we poor souls get confused with lots of stuff coming simultaneously.

So, if you are an Electronics Engineer, know C and learning Java, here is something for you. Just follow me for one hour and you will know Java. Remember these six points:
  1. Java is like C.
  2. It is platform independent.
  3. It is like C, but it is not C.
  4. It is Object Oriented Programming Language.
  5. It supports Web Application Development (J2EE)
  6. It is better than C
Lets consider each point in detail:

1. Java is like C

Well, you already know C Language.
You know how to declare variables, how to write if else, switch case, methods, calling methods and all.
Its all valid for Java as well...

Let's have a code examples:

void main(){

   int i=100;
   int j =10;
   int m,n,o;
   int k = i+j;

   m = i*j;
   n = i /j;
   o = m*m/100;

   if(i==0){
      j= i*j;
   } else {
      j= k*j;
   }

   o = sum(m,n);
}


int sum(int i, int j){
   return i+j;
}


This code is valid for both C and Java... So its simple. Isn't it?



2. It is platform independent

So what does this mean? This means something but nothing to worry as a developer.

Think of C..... I use Turbo C, rum my code and get .exe file that can be executed independently even if I don't have code. right? 

Now can I execute same .exe file over Unix/Linux? Answer is NO.
So, code written for one platform is not usable for other platforms.

So if I want to reuse the code across platforms, what do I do?
Well, Java provides solution for this problem.


This is how: