a static equivalent of 'this'?

Discussion in 'Java' started by Adam Gray, May 3, 2008.

  1. Adam Gray

    Adam Gray Guest

    Is there any way of doing the following:

    public class MyClass
    {
    private int a;
    private static int b;

    public void setA(int a)
    {
    this.a = a;
    }

    public static void setB(int b)
    {
    // is there any way to do the code in here without having
    // to use a different name for the parameter?
    }
    }
     
    Adam Gray, May 3, 2008
    #1
    1. Advertising

  2. Adam Gray wrote:
    > Is there any way of doing the following:
    >
    > public class MyClass
    > {
    > private int a;
    > private static int b;
    >
    > public void setA(int a)
    > {
    > this.a = a;
    > }
    >
    > public static void setB(int b)
    > {
    > // is there any way to do the code in here without having
    > // to use a different name for the parameter?


    MyClass.b = b;

    > }
    > }


    --

    Knute Johnson
    email s/nospam/linux/

    --
    Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
    ------->>>>>>http://www.NewsDemon.com<<<<<<------
    Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
     
    Knute Johnson, May 3, 2008
    #2
    1. Advertising

  3. Adam Gray

    Adam Gray Guest

    Knute Johnson wrote:
    > Adam Gray wrote:
    >> Is there any way of doing the following:
    >>
    >> public class MyClass
    >> {
    >> private int a;
    >> private static int b;
    >>
    >> public void setA(int a)
    >> {
    >> this.a = a;
    >> }
    >>
    >> public static void setB(int b)
    >> {
    >> // is there any way to do the code in here without having
    >> // to use a different name for the parameter?

    >
    > MyClass.b = b;
    >
    >> }
    >> }

    >


    Simple really isn't it!!
    Thanks.
     
    Adam Gray, May 3, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Natan

    Static vs. non-static connection

    Natan, May 24, 2004, in forum: ASP .Net
    Replies:
    8
    Views:
    7,370
    Sami Vaaraniemi
    May 26, 2004
  2. Ben
    Replies:
    3
    Views:
    459
  3. Martin Eyles

    MapPath equivalent from static method

    Martin Eyles, Apr 4, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    5,472
    Martin Eyles
    Apr 4, 2006
  4. dmitrey
    Replies:
    3
    Views:
    369
    sturlamolden
    Mar 15, 2007
  5. KONTRA Gergely

    C's static equivalent

    KONTRA Gergely, Aug 7, 2003, in forum: Ruby
    Replies:
    5
    Views:
    105
    Josef 'Jupp' Schugt
    Aug 7, 2003
Loading...

Share This Page