How to call method from another class?

How to call method from another class?

So I'm a rookie at OOP and I am currently having trouble using a function from another method. The class below is the main class for a card game. Here it creates a deck of cards by creating an object from the Game class. It then starts the game with the created deck and should print the size of the deck.

So I'm a rookie at OOP and I am currently having trouble using a function from another method. The class below is the main class for a card game. Here it creates a deck of cards by creating an object from the Game class. It then starts the game with the created deck and should print the size of the deck.

public class Run {

public static void main(String[] args) {

Game game;
System.out.println("Welcome!");
play = true;
while (play) {
    game = new Game(3); //Create deck of card based on number of ranks given
    game.play(); //Starts the game with deck of card
}

}

The class below is the Game class. When the game starts it should print the size of the deck created.

public class Game {
public Game(int ranks)
{
    Deck Main = new Deck(ranks);
}
public static void play()
{
    System.out.println(Main.size()); //Where the error occurs
}

The class below is the Deck class where it actually creates the deck and has a method that returns the size of that deck.

public class Deck {

private ArrayList<Card> cards;

public Deck(int range) { cards = new ArrayList<Card>(); for (int i=1; i<=range; i++) { Card card = new Card(1, i); Card card2 = new Card(2, i); Card card3 = new Card(3, i); Card card4 = new Card(4, i); cards.add(card); cards.add(card2); cards.add(card3); cards.add(card4); } } public int size() { int num=cards.size(); return num; }

The final class is the Card class.

public class Card {
private int rank;
private int suit;
public Card(int s, int r)
{
    suit=s;
    rank=r;
}
public int getSuit()
{
    return suit;
}
public int getRank()
{
    return rank;
}

It must be an obvious error due to my lack of understanding so can anyone show what to do to fix it?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Java OOPs Tutorial For Beginners | Java Object Oriented Programming

"Java OOPs Tutorial For Beginners | Java Object Oriented Programming | Java OOPs Basics" will give an introduction to Java Object Oriented Programming. Learn how to create and use OOP cocepts. Learn about all the OOP concepts: Abstraction, Encapsulation, Polymorphism, and Inheritance

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners

Polymorphism In Java — How To Get Started With OOPs?

<strong>This article on Polymorphism in Java talks about one of the key concepts of object oriented programming in depth.</strong>