Results 1 to 2 of 2

Thread: About instance variables in java

  1. #1
    CruzPowell is offline Senior Member
    Join Date
    Dec 2009
    Posts
    224
    Rep Power
    3

    Default About instance variables in java

    Hi I am new in programming world. Currently I am learning JAVA programming language..I have problem with instance variables in java. How can I find 3 instance variables that they have different type and everyone has two methods?If you are having any suggestions then reply me. It can helpful to me.


  2. #2
    BrooksGray is offline Senior Member
    Join Date
    Dec 2009
    Posts
    231
    Rep Power
    3

    Default

    Try to understand following code. It will solve your problem.

    Code:

    public class Example
    {
    int temp;
    Example()
    {
    temp++;
    }
    public static void main(String[] args){
    Example e = new Example();
    System.out.println("No. of instances for e : " + e.temp);
    Example e2 = new Example();
    System.out.println("No. of instances for e : " + e.temp);
    System.out.println("No. of instances for e2 : " + e2.temp);
    Example e3 = new Example();
    System.out.println("No. of instances for e : " + e.temp);
    System.out.println("No. of instances for e2 : " + e2.temp);
    System.out.println("No. of instances for e3 : " + e3.temp);

    }
    }
    Last edited by BrooksGray; 03-19-2010 at 01:20 PM.

Similar Threads

  1. Amazon offers free cloud-instance
    By Jakobe Green in forum Latest Hardware News
    Replies: 0
    Last Post: 10-25-2010, 07:40 AM
  2. Instance of Bean
    By RogersNguyen in forum Programming
    Replies: 1
    Last Post: 02-04-2010, 05:53 PM
  3. Replies: 0
    Last Post: 09-25-2008, 06:18 AM
  4. Creating Symbols- Instance Name & Library
    By inlgalk98 in forum Programming
    Replies: 0
    Last Post: 09-24-2008, 11:57 AM
  5. Log into another instance of Skype
    By unerina in forum Applications
    Replies: 0
    Last Post: 06-30-2008, 12:16 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48