JAVA is a computer programming language. JAVA is an object-oriented programming language. In JAVA, we deal with objects; all data is handled only by objects. It’s a simple and easily understood language. In this post, I will describe the first JAVA program. It’s a simple program that implements classes.
Code:
class Yes{
void print(){
System.out.println("My First Program of JAVA");
}
}
class Hello{
public static void main(String args[]){
Yes x = new Yes();
x.print();
}
}
In this code, there are two classes, one is Yes, and another is Hello. Yes, the class has only one method of printing, which prints the message “My First Program of JAVA.” The Hello class has the primary method and acts as a container class.
Output:
Note: Save the code in Notepad and save it as Hello.java.
Comments