"In the static block, create a Cat object and assign it to the variable cat (don't forget to initialize the field name)."
I have created the object, initialized the name and printed out the cat's name in the static block, but for some reason it does not see it.
Does anyone know what I am doing wrong?
package com.codegym.task.task15.task1518;
/*
Static modifiers and kittens
*/
public class Solution {
//public static Cat cat;
static {
Cat cat = new Cat();
cat.name = "Gati";
System.out.println(cat.name);
}
public static void main(String[] args) {
}
public static class Cat{
public String name;
}
}