File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Object  creation Problem" Watch "Object  creation Problem" New topic

Object creation Problem

Deepak here

Joined: Jul 25, 2007
Posts: 1
can smbdy pls tell me y this code doesn't work..??
public class SuperTest {
float 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:
subject: Object creation Problem
It's not a secret anymore!