Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 08-03-2009, 10:09 PM   #1 (permalink)
I don't want IT
 
DizitalNovice's Avatar
 
Join Date: Jul 2006
Location: BLR (hell part 2)
Posts: 48
Question Java Query - Apologise for not asking in query thread


Date d = new Date();
System.out.println(d);
using this statement we can see that d has got some value and can be printed. I want to make a similar class, which will assign a value to the object and not create members within the object.
Say,
Class cls{
cls(){
...
}
}

so when I write
cls cmember = new cls();
I can print SOPln(c); and not SOPln(c.<xyz>);
My Ideas:
Returning a value from constructor is not possible.
Can I know cmember from from cls, ie can I knw what variable name was used to Initialize a class?
__________________
Who said hell doesn't exist?
I stay here!!
DizitalNovice is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 09-03-2009, 09:02 AM   #2 (permalink)
Broken In
 
fabler's Avatar
 
Join Date: Aug 2008
Location: Ahmedabad
Posts: 162
Default Re: Java Query - Apologise for not asking in query thread

you can do one thing..

Initialize the member variable of your cls class in constructor. Then implement "toString" method in cls class which simply prints all the member of cls class in a format. And then you can do..

Cls c = new Cls();
System.out.println(c);

This will surely solve your problem..

Btw when you directly concat any class to with string or pass the any class in string argument, then java will call toString method of that class..
fabler is offline  
Closed Thread

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
Python Query Thread The Unknown Programming 1 27-08-2008 12:41 PM
JAVA Query Plasma_Snake Programming 6 01-08-2008 03:28 PM
Trying & Learning Ubuntu. My Query Thread narangz Open Source 129 05-07-2008 04:53 PM
Java programming query navjotjsingh Programming 7 27-10-2007 01:18 AM
Microtek Monitor Query and PHPBB Attachment Mod Query vwad Software Q&A 1 20-03-2005 09:32 AM

 
Latest Threads
- by Sujeet
- by gforz
- by soumya
- by icebags

Advertisement




All times are GMT +5.5. The time now is 03:09 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2