can we call a method from a class in an another class in java code example
Example 1: how to call a function from a class java
public class Classroom {
private String teacherName;
public Classroom(String teacherName){
this.teacherName = teacherName;
}
public String getTeacherName() {
return teacherName;
}
}
public static void main(String[] args){
Classroom firstGrade = new Classroom("John");
firstGrade.getTeacherName();
}
Example 2: how to access methods from another class in java
Beta.DoSomethingBeta();