Win a copy of Rust Web Development this week in the Other Languages forum!

siva prasaad

Greenhorn
+ Follow
since Jan 10, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by siva prasaad

Thansx Guys for your inputs...

Iam putting in brief , what i understood.
Please correct me if iam missing anything.

So ,
Thread is an independent path of execution.
For this Thread object should be created.

Now the actual work is done in run() method.

If a class implements an interface, the object of this class is called Runnable Object.

Now it is something like whichever Thread wants to perform the work, it just uses the Runnable Object to perform its job.

Is this fine.......

Thanks
Siva
Hi Manfred
In the program,you are not calling the run() method after the following code.
new Thread(r).start();

So obviously , it would not execute for second thread.

Also , How Runnable object is going to overcome the problem you mentioned.

Thanks
Siva
Hi

In java , we can implement the concept of thread , through the Thread object
and the Thread object can be created by either extending Thread Class or
implementing the Runnable Interface
In case of Runnable Interface, it has run() method , where actuall execution is done
And for this , as per the concept we should create a Runnable Object for this and should be sent as a parameter to the Thread Class Construcor


My doubt is
why should we send the Runnable Object as parameter

In general , Whenever a class imlements the Interface , it can directly use the method without the interface object...

Thanks
Siva
When to use extends Thread Class
and
When to use implements Runnable Interface.

Regards
Siva Prasad
Hi Raghavan,

Thanks a lot for the information provided.
Iam now at a better understanding of Strings.
Iam preparing for java1.5 Can you please specify the links for the good articles.

Cheers.
Siva Prasad
Hi Raghavan,
I agree with you that replace creates a new object if it is successful.

So in case 2:
As you said replace will create a new string with value "strinG", right.
So as of now one object with value "strinG" is there in String literal pool.

Now after "==" operator , we see the same funtionality of updating the "string" to "strinG".

Now in this case, since already "strinG" is created in the literal pool,
obviously there is no need to create a new string with same value in the pool.
So I think it is pointing to same object.

If this is not the case , then can we assume "Two String objects with same value in the String literal Pool".

Please clarify me.
Hi Raghavan
I had understood the case 1.

But I think in case 2 ,

"String".replace('g', 'G') will create a String object in literal pool wiht value "StrinG"
The other side of '==' operator also points to same object,since "StrinG" is already there in pool.
So as per my understanding it should goto Case1.

Please clarify me if iam wrong.

code:
--------------------------------------------------------------------------------

if ("String".replace('g', 'G') == "String".replace('g', 'G'))System.out.println("Equal");elseSystem.out.println("Not Equal");



--------------------------------------------------------------------------------

Regards
Siva
1. How "==" , "!=" work for wrapper classes.

2. What is the meaning of :"overridden methods not throwing new exceptions"
Thanks Tommaso Nuccio for your response.

I agree with you in case of overiden concept.

But i want to know what is the difference between overriden and re-define
I had read static methods cannot be overriden but can be re-defined.

Can you please tell me the difference between overriding and Re-defineing. Thanks Siva
Does the same applies for objects also??
public class demo1 {
int i;
i=0;
public static void main(String args [])
{
System.out.println("Demo Program Execution");
}

}
and
public class demo1 {
int i=0;
public static void main(String args [])
{
System.out.println("Demo Program Execution");
}

}

The only change i made:
1st prog:int i;
i=0;

2nd Prog:int i=0;

Which is correct...


(title edited to quieten it down to a question rather than a shout)
[ February 15, 2007: Message edited by: Barry Gaunt ]
hi folks..
Iam also planning to take it around the same time.
But may i know the place where to post the queries and discuss them for
our SMART group.
My mail ID cvaugh@gmail.com
What is difference in the following declarations

int i=5;

int i;
i=5;

Also what are compile time constants.