Java Example


public class Simple{  
    public static void main(String args[]){  
     System.out.println("Hello Makkena Srinivasa Rao");  
    }  
public class Simple{
In Java, every line of code that can actually run needs to be inside a class. This line declares a class named Simple, which is public, that means that any other class can access it. Notice that when we declare a public class, we must declare it inside a file with the same name (Simple.java), otherwise we'll get an error when compiling.
public static void main(String[] args) {
This is the entry point of our Java program. the main method has to have this exact signature in order to run our program.
public again means that anyone can access it.
static means that you can run this method without creating an instance of Main.
void means that this method doesn't return any value.
main is the name of the method.
The arguments we get inside the method are the arguments that we will get when running the program with parameters. It's an array of strings. We will use it in our next lesson, so don't worry if you don't understand it all now.
System.out.println ("Hello Makkena Srinivasa Rao");
System is a pre-defined class that Java provides us and it holds some useful methods and variables.
out is a static variable within System that represents the output of your program (stdout).
println is a method of out that can be used to print a line.


Share:

1 comment:

Ordered List

Popular Posts

The Magazine

Facebook

Post Top Ad

LightBlog

Post Top Ad

Your Ad Spot

About Me

authorHello, my name is Jack Sparrow. I'm a 50 year old self-employed Pirate from the Caribbean.
Learn More →

Comment

Post Top Ad

Your Ad Spot

Hot

AD BANNER

Sponsor

AD BANNER

Recent Comments

Extra Ads

AD BANNER

Contact Form

Name

Email *

Message *

Translate

Sponsor

test

Home Top Ad

Responsive Ads Here

Flickr

Ad Banner
Responsive Ads Here

About Us

authorHello, my name is Jack Sparrow. I'm a 50 year old self-employed Pirate from the Caribbean.
Learn More →

Recent Posts

Unordered List

  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  • Aliquam tincidunt mauris eu risus.
  • Vestibulum auctor dapibus neque.

Sample Text

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation test link ullamco laboris nisi ut aliquip ex ea commodo consequat.

Pages

Theme Support

Need our help to upload or customize this blogger template? Contact me with details about the theme customization you need.