Powered by Blogger.

Another Java Program for beginners | Java Programming

The name of the source file must be the same as the name of the public class declaration in that file. A source file can include more then one class declaration, but only one class can be declared public.

public class Welcome{
public static void main(String[]args){
Hello hello = new Hello();
  hello.display();
}
 }

 class Hello{
  public void display(){
System.out.println(”Welcome to Java world”);
  }
 }



Line 3 creates an object of Hello class named hello

Line 4 call the display() method of Hello class using the hello object
with the dot notation.

Line 8 declares a user-defined class Hello with default access control.

Line 9 declares a user-defined method named display().

2 comments:

  1. I really enjoy the blog.Much thanks again. Really Great.
    Very informative article post. Really looking forward to read more. Will read on…


    oracle online training
    sap fico online training
    dotnet online training
    qa-qtp-software-testing-training-tutorial

    ReplyDelete
  2. I appreciate you sharing this article. Really thank you! Much obliged.
    This is one awesome blog article. Much thanks again.

    sap online training
    software online training
    sap sd online training
    hadoop online training
    sap-crm-online-training

    ReplyDelete