# New variable inside static method

**URL:** <https://verificationacademy.com/forums/t/new-variable-inside-static-method/48296>\
**Category:** SystemVerilog\
**Tags:** static-method\
**Created:** [August 24, 2024, 9:19pm UTC](https://verificationacademy.com/forums/t/new-variable-inside-static-method/48296 "2024-08-24T21:19:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Avii](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@Avii](https://verificationacademy.com/forums/u/Avii)\
**Post date:** [August 24, 2024, 9:19pm UTC](https://verificationacademy.com/forums/t/new-variable-inside-static-method/48296/1 "2024-08-24T21:19:10Z")

</div>

```auto
class avi;
  int b;
  static int c; 
  static function int kk();
    int d;
    d++;
    return d;
  endfunction  
endclass

module max;
  avi a;
  initial repeat(3) begin
    $display("%0d",a.kk());
  end
endmodule

```

The new variable d inside the static method is not behaving like a static variable. why ?

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [August 25, 2024, 6:05am UTC](https://verificationacademy.com/forums/t/new-variable-inside-static-method/48296/2 "2024-08-25T06:05:08Z")

</div>

Class methods _always_ have an _automatic_ lifetime. The variable `d` has an implicitly _automatic_ lifetime.

The `static` method qualifier comes before the `function` keyword. This means the method may be called without constructing the class. Static methods must not reference class instance specific members (like `b` in your example).
