Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

naming convention question  RSS feed

 
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.
 
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.
 
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!