Did you create a Dog object using the Dog constructor? Make sure you indicate an integer parameter

class Dog {
static int age=5;
Dog()
{
//age=5;
}

public static void main(String[] args) 

{

Dog spike= new Dog();

System.out.println(spike.age);

}

}

@webpro69971,
If you use a //
everything after this // is seen as comment and will NOT be executed as code

@webpro69971,

Please read
https://docs.oracle.com/javase/tutorial/java/javaOO/classdecl.html
and
https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html

With

Dog() { 
      age=5;
	}

you are trying to define a so-called no-argument constructor
but you will have to pre-pend this constructor definition
with one of the =modifiers= public or private…
thus
in this case you would use

public Dog() { 
      age=5;
	}

With

Dog spike= new Dog();

you Instantiate the DOG-class,
meaning you create an Object using the DOG-class-constructor…

spike = {
   age: 5
  }