wood burning stoves*
The moose likes Beginning Java and the fly likes Object  creation Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Object  creation Problem" Watch "Object  creation Problem" New topic
Author

Object creation Problem

Deepak here
Greenhorn

Joined: Jul 25, 2007
Posts: 1
can smbdy pls tell me y this code doesn't work..??
public class SuperTest {
float f;
SuperTest()
{
this(f);
f = 0.1f;

}
SuperTest(float f)
{
System.out.println("called test"+f);
}
public static void main(String[] args) {
SuperTest st =new SuperTest();

}
}
Guido Sautter
Ranch Hand

Joined: Dec 22, 2004
Posts: 142
Hi Deepak,

it seems you pass the local field f to the second constructor, where you print it to System.out. Only after that, you assign 0.1 to it. So i guess the output is always "called test0.0".
What output did you expect, or what does not work. If you are more specific in your questions, it's way easier to give specific and useful answers.

Cheers, Guido
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Object creation Problem
 
Similar Threads
decimal part of a float
Constructor Problem
Float.valueOF() problem
Doubt in method call
Exception in constructor