Results 1 to 2 of 2

Thread: About instance variables in java

  1. #1
    Join Date
    Mar 2010
    Posts
    1

    About instance variables in java

    Asslam Alikum

    I have prblem with instance variables in java ..

    How can I find three instance variables that they have different type and each one have tow method?

    (Your class should have constructor that initializes the three instance variables)) what does it mean ??

    I wait you >>

  2. #2
    Join Date
    Feb 2010
    Posts
    136

    Re: About instance variables in java

    Hello,
    I think this is what you are looking for
    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);
    
          }
    }

Similar Threads

  1. What are an Atomic Variables in Java?
    By Dilbert in forum Software Development
    Replies: 5
    Last Post: 04-01-2011, 07:51 PM
  2. How to create an instance of Bean in java?
    By Madaleno in forum Software Development
    Replies: 4
    Last Post: 03-02-2010, 09:33 PM
  3. What is Instance variables in Java?
    By Owen Fernandes in forum Software Development
    Replies: 5
    Last Post: 23-01-2010, 08:27 AM
  4. Multiplying Variables in java
    By WinDoWLoCuS in forum Software Development
    Replies: 3
    Last Post: 03-12-2009, 01:43 PM
  5. Replies: 5
    Last Post: 02-03-2009, 09:00 PM

Tags for this Thread

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
  •  
Page generated in 1,713,559,709.90018 seconds with 17 queries