Results 1 to 7 of 7

Thread: Java Inconsistenties [resolved]

Threaded View

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Java Inconsistenties [resolved]

    I noticed some things in Java that im not sure why they are allowed. Any comments?

    1.) why does a constructor allow static members to be initialized?

    2.) why is a non static member able to be initialized out side
    of its class constructor?

    Code:
    // why does a constructor allow static members to be initialized? 
    // why is a non static member able to be initialized out side 
    // of its class constructor?
    
       class Test2{
         static int x;
         static int w = 54; 
         int z = 56; 
        public Disassembler(){
          x = 73; // ?  
         
       }
      }
    
      public class Test1{
        public static void main(String[] args){
    
         Disassembler d = new Disassembler(); 
          System.out.println(Disassembler.x);
          System.out.println(Disassembler.w);
          System.out.println(d.z);
      }
    }
    Last edited by Dilenger4; Oct 1st, 2001 at 03:19 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width