"In addition to static methods, there are static classes. We'll discuss these in more detail later. For now, let me just show you an example:"

Example:
public class StaticClassExample
{
    private static int catCount = 0;

    public static void main(String[] args) throws Exception
    {
        Cat bella = new Cat("Bella");
        Cat tiger = new Cat("Tiger");

        System.out.println("Cat count " + catCount);
    }

     public static class Cat
    {
        private String name;

        public Cat(String name)
         {
            this.name = name;
            StaticClassExample.catCount++;
         }
     }

}
undefined
6
Task
New Java Syntax, level 6, lesson 7
Locked
Displaying arrays
Implement the main(String[]) method, which displays the strings and ints arrays on the console using the Arrays.toString() method.

"You can create as many Cat objects as you want. But this isn't the case with a static variable. Only one copy of a static variable exists."

"The main purpose of using the static modifier in the class declaration is to control the relationship between the Cat and StaticClassExample classes. The idea is roughly this: the Cat class is not linked to StaticClassExample objects and can't access the instance (non-static) variables of the StaticClassExample class."

"So I can create classes inside classes?"

"Yes. Java allows that, but don't give it too much thought right now. It will become clearer when I explain some more things to you in the future."

"I hope so, Rishi."

undefined
6
Task
New Java Syntax, level 6, lesson 7
Locked
Displaying two-dimensional arrays
Implement the main(String[]) method, which displays the strings and ints arrays on the console using the Arrays.deepToString(Object[][]) method.
undefined
6
Task
New Java Syntax, level 6, lesson 7
Locked
Comparing two-dimensional arrays
Fix the logic of the main(String[]) method. It should display true if arrayFirst is the same as arraySecond. Otherwise, it should return false.