Current location - Recipe Complete Network - Food world - How can two classes in the same project of JAVA program access each other?
How can two classes in the same project of JAVA program access each other?

For example, if you have a class A ... and a class B

public class A {

public static void main (string [] args) {

/Here you need to call a method of b ... You can get the b object through New

b b= new b ();

b.speak();

}

}

public class b {

public static void speak () {

system. out.println ("thank you");

}

}

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