![]() |
![]() |
![]() |
![]() |
![]() |
|
You do not need to define a method called in the
main method in the same class in which you define that main
method. For example, you can define movieRating in
the Movie class in the Movie.java file:
// Movie class defined in Movie.java
public class Movie {
public static int movieRating (int s, int a, int d) {
return s + a + d;
}
}
Then, you can define main in the
Demonstrate class in the Demonstrate.java file:
// Demonstrate class defined in Demonstrate.java
public class Demonstrate {
public static void main (String argv[]) {
int script = 6, acting = 9, direction = 8;
System.out.print("The rating of the movie is ");
System.out.println(Movie.movieRating(script, acting, direction));
}
}