Current location - Loan Platform Complete Network - Big data management - How can two classes in the same project of a JAVA program access each other?
How can two classes in the same project of a JAVA program access each other?
Say you have a class a... And a class b

public class a{

public static void main(String [] args){

//Here you have to call one of the methods of B.... You can get the B object via New

b b= new b();

b.speak();

}

}

public class b{

public static void speak(){

System. out.println("Thanks");

}

}

}

You can access each other's methods by creating an object of another class by new in the class...