So, i am back after a long long break..actually was busy with some stuff,my new novel and some more projects.

Though a lot of programming tutorials will start out with some dazzling stats and boring history about the language.  I’d rather take a straight route and start with an actual program.

So, lets begin.please refer to the comment and the text that follows the code( i assume that you know a bit of c or c++)


public class GreetingTest { // a class declaration..will come to it later
/**same old main function for c programmers only its called a method though its hard to recognize.*/
public static void main(String args[]) {

Greetings obj = new Greetings();// object declaration and creation
obj.displayGreetings ; /**method call to an object method named displayGreetings..*/
}
}
public class Greetings { // another class declaration :P
Greetings(){};//contructor defination
void displayGreetings() { // method defination
System.out.println("hello cruel world");/*same as cout and printf of c++ and c...only its a bit different and a bit too long*/
}
}

Ok, i know this an awkward code,but don’t be dazed cause its not that trivial(though I know it is:P)
We, know that java is a bit cranky and object oriented so it does everything with a difference..so we’ll learn it in other more deep posts..

Advertisements