General Java Questions II
Answer: Because you have included the return type  void  in the method declaration,
it becomes a normal method, that just happens to have the same name as the class  
so it won t get used as a constructor. Remove the  void  and it should work.
  
Vince Bowdren
P.S. by John: If you do not specifically define any constructors, the compiler inserts
an invisible zero parameter constructor "behind the scenes". Often this is of only
theoretical importance, but the important qualification is that you only get a default
zero parameter constructor if you do not create any of your own.
Your program used this zero parameter constructor and you saw nothing...
Q: Why we can not declare constructor as final ?
Answer: The keyword final when dealing with methods means the method cannot be
overridden. 
Because constructors are never inherited and so will never have the oportunity to be
overridden, final would have no meaning to a constructor.
Q: In Java, does exist a function like sprintf in C ?
Answer: 
http://www.efd.lth.se/~d93hb/java/printf/index.html
 a free Java version of
fprintf(), printf() and sprintf()   hb.format package
Q: If I declare an array of an objects, say Dogs, is that memory taken when I
create the array or when I create the objects in the aray when I declare this array: 
Dog[] dog = new Dog[100];
or does it take the memory when I actually create the Dogs in the array eg: 
for(int i = 0;i
Answer: The statement above is actually two fold. It is the declaration and
initialisation of the array. Dog[] dog is the declaration, and all this does is declare a
variable of type Dog[], currently pointing to null.
 You then initialise the array with new Dog[100], which will create 100 elements in the
array, all of them referencing null. 
It is important to realise that the elements of an array are not actually objects, they
only reference objects which exist elsewhere in memory. When you actually create
the Dog objects with new Dog(), these objects are created somewhere in memory
and the elements in the array now point to these objects. 
Pedant point:
Nothing ever points to null. It is a constant that represents the value of a reference
variable that is not a pointer to some object  new Dog[100] creates an array of 100
null Dog references.
Q: How do I return more than one value using the return command?
Answer: You could make a new object/class that contains these two values and
return it. For example:
Define an object like this:
class MyObj {
   public int myInt;
   public double myDouble;
file:///F|/a_jsite/350_tips/general_java II.htm (3 of 14) [2001 07 08 11:24:53]






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java web hosting

 

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved