Ravinder Partap

Greenhorn
+ Follow
since Feb 03, 2008
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 Ravinder Partap

this is fine, but you could avoid the explicit casting as its done implecitly while widening 16 bit char to 32 bit int primitive.
int i= (int)c;
is equal to :
int i = c;
14 years ago
Every object in Java has a corresponding lock and that lock is used in multithreading enviornment to ensure the desirable access to the methods or the block of code.
When there are more than one thread working on the non-static methods (or the block of code in those methods.) than the lock taken on the object (the instance of some class) is taken by the thread and no other thread with the same instance of object can access those methods if they are synchronized. That means by synchronizing the method, you will ensure that any threads trying to run that method using the same instance will be prevented from simultaneous access.
But thread working with a different instance will not be affected, because it's acquiring a lock on the other instance.
14 years ago
Thanks Kamlesh ! Your second answer cleared all my doubts.
14 years ago
Oh, I forgot that while experimenting all the option I already had used variable h.
Still converting this variable "h" to "h1" in following line

Hello h=new sub();// this is not compiling

Make it as:-

Hello h1 = new sub();

Now still it doesnt gets compiled.
14 years ago
Code:

public class Hello
{
public Hello()
{
System.out.println("a");
}
public void test(){}
public static void main(String arg[])
{
Hello h = new Hello();
Hello h=new sub();// this is not compiling

}
class sub extends Hello
{
Hello h=new sub();
public sub()
{
super();
System.out.println("s");

}

}
}

Query:- Why we can't do "Hello h=new sub();" in the main method in this class?
14 years ago
I want to ask Is int e# illegal identifier name ? Why.
14 years ago