Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-24-2008, 12:56 PM
Member
 
Join Date: Dec 2008
Posts: 2
Rep Power: 0
alksam is on a distinguished road
Default what the outPut
in this program when you compile it, don't give u any problem. but when you run, doesn't work,

public class Test {

String text;

public void Test(String s) {
this.text = s;
}

public static void main (String[ ] args) {
Test test = new Test("ABC");
System.out.println(test);
}
}
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 12-24-2008, 03:35 PM
Senior Member
 
Join Date: Jun 2008
Posts: 1,397
Rep Power: 3
masijade is on a distinguished road
Default
Describe "doesn't work", as I can guarantee that it produces exactly what you've told it to produce.

P.S. You probably meant "test.text".
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-24-2008, 05:04 PM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,159
Rep Power: 3
CJSLMAN is on a distinguished road
Default A couple of things...
First, remove the "void" from your constructor. As far as I know, constructors never return anything (FYI... it wouldn't compile for me with that void there).
Second, as masijade mentioned, use test.text in your println statement.

Luck,
CJSL
__________________
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-24-2008, 06:04 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Yes, the following is wrong with instantiate.

Code:
public void Test(String s) {
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-25-2008, 06:06 AM
Member
 
Join Date: Dec 2008
Posts: 2
Rep Power: 0
alksam is on a distinguished road
Default
thank u for all, i knew where is the problem
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 12-25-2008, 02:44 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Nice, if you have solve the problem please mark it as solved.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
different output pro85 Java Applets 6 08-05-2008 02:42 PM
xsl:output tag JavaForums Java Blogs 0 07-25-2008 03:30 PM
What will be output and why huma Threads and Synchronization 4 06-26-2008 11:14 PM
Why the output is always zero mehrotra.chitij New To Java 12 04-25-2008 05:05 AM
output Camden New To Java 3 12-01-2007 11:34 PM


All times are GMT +2. The time now is 05:51 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org