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().
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().
I really enjoy the blog.Much thanks again. Really Great.
ReplyDeleteVery 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
I appreciate you sharing this article. Really thank you! Much obliged.
ReplyDeleteThis 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