Simple JAVA program

Simple JAVA program

Object – I will take some real world examples to make this easy. In our real world, there are many objects such as cars, clothes, dogs, cats etc.: All their objects have a state or/and a behavior. If we take the object as cat, the state can be name, color, breed and the behavior can be eating, playing, purring etc. Just like that in Java also the object has states and behaviors. A state of a software object is stored in the fields and the behaviors are shown via methods. (Methods operate on the state of the object and the object to object communication is done via methods.)Class – By using classes we can create different objects.

Public – Which means it is visible to all. Represents the visibility.

Static – If a method is static we do not need to create object to invoke the static method.

Void – This is the return type of the method which means it does not return any value.

Main – Indicates the startup of the program.

Following is a very basic type of a Java program. 

public class Fish{
 string color;
 string name;
 void swimming(){
 void eating(){
 void sleeping(){
How to run your Java program?

Open your Notepad and write a simple java program as above. Save the file as To compile and run the program, go to your command prompt and give the command to run the new

Java simple

Thamali Epa

Thamali is a contributor at Nerdynaut Staff.

  • Fascinated
  • Happy
  • Sad
  • Angry
  • Bored
  • Afraid



    February 27, 2016 at 6:21 pm

  2. Tayna

    April 26, 2017 at 5:08 pm

    Great – I should definitely pronounce, impressed with your site. I had no trouble navigating through all the tabs as well as related information ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Reasonably unusual. Is likely to appreciate it for those who add forums or anything, website theme . a tones way for your client to communicate. Nice task..

  3. enterrement vie de garcon ile de France

    April 26, 2017 at 8:31 pm

    It’s actually a nice and useful piece of information. I am satisfied that you just shared this helpful information with us. Please stay us up to date like this. Thanks for sharing.

  4. ssc recruitment

    April 27, 2017 at 8:29 pm

    you’re really a good webmaster. The website loading speed is amazing. It seems that you are doing any unique trick. In addition, The contents are masterpiece. you have done a wonderful job on this topic!

  5. Florencio

    April 29, 2017 at 7:38 pm

    This can be the best blog for any individual who wants to find out about this subject. You comprehend so much its nearly challenging to argue with you (not that I really would want…HaHa). You unquestionably put a brand new spin on a subject thats been written about for years. Wonderful stuff, just terrific!

  6. Rashida

    May 1, 2017 at 12:34 pm

    Hello. impressive job. I did not anticipate this. This is a splendid story. Thanks!

  7. Darrin

    May 5, 2017 at 12:41 pm

    I do believe all the concepts you have presented in your post. They’re really convincing and can certainly work. Nonetheless, the posts are too quick for novices. Could you please lengthen them a bit from subsequent time? Thank you for the post.

Leave a Reply

Your email address will not be published. Required fields are marked *

This Month's Most Popular Posts

AdvertisementBooks by Nerdynaut
To Top