Objectives:
  • how to create a class
    • how to call a method
    • how to create a method
  • how to call another method in a different class
  • Code : Test_This.java.txt

//import java io.*;
//javac Test_this.java
public class Test_this
{
public static void main(String args[])//this is an netry function must have
{
int f10 = 5;
int n1=10;
System.out.println(f10 + n1 + "hello world");
//to track another method
//class-name cc = new class-name();
Test_this m5= new Test_this();// creating object from a class
m5.method1();//calling a method via an object
baba m6= new baba();
m6.method2();

}
public void method1() // this how you define a method
{ //method body starts here
//a function needs a body to do something
double j2 = 12.2;
System.out.println(j2);
}//method's bosdy ends here

}//main clas ends here
class baba
{

public void method2()
{
System.out.println(" new mthod");
}
}

Rules are
  1. using a header library
  2. name a class and save as the name_of_class.java
  3. in a class there will be always one main function as the entry point