• Post Reply Bookmark Topic Watch Topic
  • New Topic

naming convention question  RSS feed

 
Hagaya Hatake
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell my why in java if my class is MyClass then my file will be named as MyClass.java??

What the class constructor really does?

Amd how does the array subscript operator works.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Hagaya Hatake:
Can anyone tell my why in java if my class is MyClass then my file will be named as MyClass.java??


That's simply what Sun's compiler requires and is a pretty common convention. It is not required by the JLS, but it would be a real pain to locate the proper source file in a file-based system if the compiler didn't have those kinds of requirements.

Originally posted by Hagaya Hatake:
What the class constructor really does?


Well every constructor except for Object must invoke another constructor of the same class or a constructor of it's super class. Other than that it merely executes whatever code is contained in it.

Originally posted by Hagaya Hatake:
Amd how does the array subscript operator works.


By that I assume you mean an array access expression using [] to access a variable of an array. Basically the int between the brackets, and it must be an int or something that can be promoted to an int, accesses the variable in the array at that index. The index starts at 0. So if I create an Object[] named obj of length 5 and I want to access the 5th variable then I will use obj[4] to access the variable at index 4. I purposely call them variables because that's what they are, you are not accessing an Object, you are accessing a reference variable which either points to an Object or is null.
 
Kentaro Shinbashi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Hatake.


What the class constructor really does?


By this question, are you asking what happens with the JVM when you instantiate a class? That is, are you asking step by step what goes on in the computer?


Kentaro
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!