Pradyumna Hari

+ Follow
since May 27, 2002
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Pradyumna Hari

Hi all,
Can any one tell me what is the equivalent of
eval function ( this is a function in javascript ) in java. The requirement is to evaluate the value of an expression but the expression is itself a string.
ClassA a = new ClassA();
String strExpression = "a.getName()" ;

Now I want to print the value returned by a.getName(). Is there any function ftn such that
System.out.println(ftn(strExpression)) would print the value returned by a.getName()

[ June 04, 2002: Message edited by: Pradyumna Hari ]
18 years ago
Hi Chris,
In my experience I have seen use of interfaces in
(1) For multiple inheritance
(2) For declaring constants, since all data members in interfaces are static and final.
(3) For the obvious reason of, declaring an interface, which can be implemented by some class.
I suggest reading " Thinking in java" by bruce eckel. It is freely available on the web, . This gives insight on not only how but also why of things.
18 years ago
Hi arun,
Here are the answers :
(1) Yes. Class is loaded in memory when there is reference to any of its static fields/methods or when an instance of class is created.
(2) The memory occupied by class B would be reclaimed by Garbage collector as there is no reference to any object of class B.
(3) Yes. GC will release memory of those objects for which there does not exist any reference. When would the garbage collector run is either when your jvm is falling short of memory allocated to it by cpu or when you force the GC to run ( though it does not relent to any force, I suppose )
18 years ago
Hi tyler,
I implemented suggestion of Dirk and this code works as you expected.

[ May 31, 2002: Message edited by: Pradyumna Hari ]
18 years ago
Hi lee,
Please do post your html and the names of images used. I would be interested to analyse your program.
18 years ago
Hi Nick,
Regarding transparency question, I tried something in the alpha value of the constructor to create Color:
I list my findings if it helps you :
This is an applet. You need to use appletviewer.
Code for applet

Code for html

To see the change that alpha value makes you alter the applet code line 19 as
c = new Color(0,0,255,20);
c = new Color(0,0,255); and see the result.
I hope I did not answer something you did not ask.
18 years ago
Could any one please tell me the way to find out how much time a particular java program takes to run.
Thanks :roll:
18 years ago
Hi Kevin,
Here is the sample code. To run this you need to provide the string you want to test as one command line argument : java Ex4 Some23Argument

18 years ago
Hi Larry,
I could not get your first question. Here is the reply for second and third questions.
(2) Here is the code that overrides the toString() method to get the string you want :

(3) To get the output of code fragment, you have to do some modifications. Here is the modified code :

The output is

And if you see the javadocs for equals() method of point, it makes things very clear :

public boolean equals(Object obj)
Determines whether two points are equal. Two instances of Point are equal if the values of their x and y member fields, representing their position in the coordinate space, are the same.
equals in class Point2D
obj - an object to be compared with this point.
true if the object to be compared is an instance of Point and has the same values; false otherwise

[ May 29, 2002: Message edited by: Dirk Schreckmann ]
18 years ago
I was wondering what this "Java College" all about. Some soul throw some light please!
18 years ago
Hi Abdul,
I guess you are asking a beginner question :
There are two ways:
(1) Through console
Please go thorough the code below

(2) Through GUI
Here is the crude code. You would need to read about ActionListeners to understand this

18 years ago
Hi Mitchell,
Here is the code that shows how you can use your font to display. This is an applet.
Applet Code

HTML File Code

18 years ago
Hi I modified the code to reflect what you want.

[ May 27, 2002: Message edited by: Dirk Schreckmann ]
18 years ago
On the outskirts of town, there was a big old pecan tree by the cemetery fence. One day two boys filled up a bucket with nuts and sat down by the tree, out of sight, and began dividing the nuts. "One for you, one forme.
One for you, one for me," said one boy. Several were dropped and rolled down towards the fence.
Another boy came riding along the road on his bicycle. As he passed, he thought he heard voices from inside the cemetery. He slowed down to investigate. Sure enough, he heard, "One for you, one for me. One for you and one for me." He just knew what it was. "Oh my," he shuddered, "it's Satan and the Lord dividing the souls at the cemetery.
He jumped back on his bike and rode off. Just around the bend he met an old man with a cane, hobbling along. "Come here quick," said the boy, "you won't believe what I heard. Satan and the Lord are down at the cemetery dividing up the souls."
The man said, "Beat it, kid, can't you see it's hard for me to walk?"
When the boy insisted, though, the man hobbled to the cemetery. Standing by the fence they heard, "One for you, one for me. One for you, one for, me."
The man whispered, "Boy, you've been telling the truth. Let's see if we can see the devil himself."
Shaking with fear, they peered through the fence, but were still unable to see anything.
The old man and the boy gripped the wrought-iron bars of the fence tighter and tighter as they tried to get a glimpse of Satan.
At last they heard, "One for you, one for me. And one last one for you.
That's all. Now let's go get those nuts by the fence, and we'll be done."
They say the old guy made it back to town 5 minutes before the boy.
18 years ago