Results 1 to 2 of 2
  1. #1
    glockner is offline Member
    Join Date
    Jan 2015
    Posts
    31
    Rep Power
    0

    Default Instance variable for objects?

    I am working on a project and it asks me to "Provide appropriate names and data types for each of the instance variables. Maintain two GVdie objects" under class fields. I am unsure as to what is being asked when asking for two objects as instance variables and how I would write that...

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    16

    Default Re: Instance variable for objects?

    An instance variable is just a variable defined at the class-level, as a member of any instance of that class.

    More info here, at the first result for googling "java instance variables": Understanding Class Members (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    Java Code:
    public class Example{
       private int x; //this is an instance variable
       private String name; //this is an instance variable
    
       static int z; //this is NOT an instance variable
    
       public void example(){
          int abc = 123; //this is NOT an instance variable
       }
    }
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

Similar Threads

  1. local variable and instance variable
    By dhia annur in forum New To Java
    Replies: 7
    Last Post: 12-24-2013, 05:01 AM
  2. Replies: 1
    Last Post: 04-21-2012, 07:03 PM
  3. Array of objects, as an Instance variable
    By blaklite in forum New To Java
    Replies: 2
    Last Post: 03-25-2009, 01:56 AM
  4. Instance Variable In Servlet
    By javarishi in forum Java Servlet
    Replies: 3
    Last Post: 06-14-2008, 09:28 AM
  5. Instance variable
    By Jack in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 05:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •