This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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 Elasticsearch in Action this week in the Big Data forum!
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
jQuery in Action, 2nd edition
subject: Object creation Problem